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

 

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 "?

 

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.

 

Fractions of pips eh? Why would you want that?

Am I missing something?


CB

 
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.

 
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.

 
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

 
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) 
}

Reason: