MQL4 - automated forex trading   /  

Forum

"int" or "double" for command for Slippage?

Back to topics list To post a new topic, please log in or register

avatar
58
aj34997 2009.11.09 22:03 

I've seen it used both ways. Right now i've got it set up as " extern int Slippage ". I have included the file <stdlib.mqh>. The command line I am using is the following. OrderSend(Symbol(),OP_BUYSTOP,Lots,dropped,Slippage,dropped-(SL*Point),dropped+(TP*Point),"simple buy stop",Green)

Can I set it up as " extern double Slippage "?

Two-Stage Modification of Opened Positions

Two-Stage Modification of Opened Positions

The two-stage approach allows you to avoid the unnecessary closing and re-opening of positions in situations close to the trend and in cases of possible occurrence of divirgence.


avatar
2240
Roger 2009.11.09 23:15 

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

No you can't set slippage as a double.


avatar
1397
cloudbreaker 2009.11.10 01:44 

Fractions of pips eh? Why would you want that?

Am I missing something?


CB


avatar
58
aj34997 2009.11.10 07:43 
Roger:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

No you can't set slippage as a double.

Thanks for the answer and including the command string. This could come in handy in the future. In fact I've already printed it out.


avatar
58
aj34997 2009.11.10 08:16 
cloudbreaker:

Fractions of pips eh? Why would you want that?

Am I missing something?


CB

What you are missing is that I am not a programmer. I've learned to make uncomplicated changes to programs by seeing how other programs are written that have coding for doing something that I want the program I am working on to do. When I saw the above slippage code written in different ways from 2 different programs I decided to ask. It looks as if one of the programs I was looking at has made a coding error. I suppose I should start to read the documentation on this site.


avatar
1397
cloudbreaker 2009.11.10 15:14 
aj34997:

What you are missing is that I am not a programmer. I've learned to make uncomplicated changes to programs by seeing how other programs are written that have coding for doing something that I want the program I am working on to do. When I saw the above slippage code written in different ways from 2 different programs I decided to ask. It looks as if one of the programs I was looking at has made a coding error. I suppose I should start to read the documentation on this site.

Ah, I get it. Put very simply, "int" defines a variable which is a whole number whereas "double" defines a variable which is a number with decimal places.


CB


avatar
4328
WHRoeder 2009.11.10 16:10 
Roger:

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

No you can't set slippage as a double.

The wrinkle is the unit of slippage is points not pips so constants must be adjusted:

//---- These are adjusted for 5 digit brokers.
double  pips2points         = 1,
        pips2dbl,       //  = Point
        slippagePoints; //  = SlippagePips * pips2points;
int init()
{
    pips2dbl         = Point;
    if (Digits == 3 || Digits == 5) {
        pips2points *= 10;
        pips2dbl    *= 10;
    }
    slippagePoints  = SlippagePips * pips2points;
}
int start(){
  //OrderSend(Symbol(), OP_BUYSTOP, Lots,dropped,
  //Slippage, dropped-(SL*Point), 
  dropped+(TP*Point),
  //"simple buy stop",Green) 
  OrderSend(Symbol(), OP_BUYSTOP, Lots,dropped,
  slippagePoints, dropped-(SL*pips2dbl),
  dropped+(TP*pips2dbl),
  "simple buy stop",Green) 
}


Back to topics list  

To add comments, please log in or register