Problem in Stoploss help please

 

Dear all

i have a problem in stop loss its not working, i need help in correcting it

thanks in advanced

OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask+Step*Point,3,Ask+(Step-SL)*Point,Ask+(Step+TP)*Point,"",12321,0,Green);
  OrderSend(Symbol(),OP_SELLSTOP,Lots,Bid-Step*Point,3,Bid-(Step+SL)*Point,Bid-(Step+TP)*Point,"",12321,0,Red);
 
Possible reason is that SL is too close to open price. In your case this should be checked: SL- MarketInfo(Symbol(),MODE_SPREAD) > MarketInfo(Symbol(),MODE_STOPLEVEL). TP also can be checked because they usually gives common error - Invalid SL/TP. Also note that Pending orders should be at the same STOPLEVEL distance from current price.


 
  1. EA's should adjust TP, SL, AND slippage for 5 digit brokers. On ECN brokers you must open the order and then set stops.
    //++++ 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
    
  2. Always test return codes so you know WHY
    int ticket = OrderSend(...);
    if (ticket<0) Alert("OrderSend failed: ",GetLastError());

 

Hi, one possible reason can be that some Mt4 brokers don't accept orders with SL and TP. First you must send order with SL =0 and TP = 0, and later modify it to de desired levels.

You can see example how to do it using this mq4 EA generator