question on ordersend error 138

 

Hi Pros,

When I test the EURUSD history data, there is no error:

OrderSend(Symb,OP_BUY,0.2,Ask,2,SL,TP);

When I live trading, it always reports error 138. It still opens the order but reduce the lots from 0.2 to 0.12.

Could anybody tell me why this is happening? Should I make the slippage parameter larger to avoid this?

Thank you so much

 
On a 5 digit broker your slippage of 2 means 0.2 pips. EA's must adjust TP/SL, AND slippage.
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
    if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
 
Show your code otherwise we have to guess . . .
 
WHRoeder:
On a 5 digit broker your slippage of 2 means 0.2 pips. EA's must adjust TP/SL, AND slippage.


Yes I am using a 5 digit broker.

If I increase slippage to 10, it would work, right?

Thank you!

 
WHRoeder:
On a 5 digit broker your slippage of 2 means 0.2 pips. EA's must adjust TP/SL, AND slippage.

But why does the metatrader reduce my 0.2 lot to 0.12 lot, when the error 138 happens. This wierd...
 
zbleach:

But why does the metatrader reduce my 0.2 lot to 0.12 lot, when the error 138 happens. This wierd...
Only explanation I can GUESS at is that your code is changing the lot size . . . . best I can do.
Reason: