OrderModify error 1 (trailing stop)

 
Hello,

I have a problem related to the trailing stop, if I use it less than 15 PIPS it returns this error

----- OrderModify error 1

Please, does anyone know how to fix it in the code because I want to work with lower levels of trailing stop.


void TrailingStops()
  {
  for(int i = 0; i < OrdersTotal(); i++)
     {
      bool OrSel = OrderSelect(i, SELECT_BY_POS);    
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && UseTrailingStop && TrailingStopStep * PipValue > 0 && TrailingStopStart * PipValue > 0) 
        { 
        if(OrderType() == OP_BUY) 
          { 
          if(Bid - OrderOpenPrice() > TrailingStopStep* point && Bid - OrderOpenPrice() > TrailingStopStart * point) 
            {
             if(OrderStopLoss() < (Bid - TrailingStopStep* point))
                bool modify = OrderModify(OrderTicket(), OrderOpenPrice(),Bid - TrailingStopStep* point, OrderTakeProfit(), 0, clrLime);
                }
             }                       
        if(OrderType() == OP_SELL)          
           {
           if(OrderOpenPrice() - Ask > TrailingStopStep* point && OrderOpenPrice() - Ask > TrailingStopStart * point)
             {
             if(OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStopStep* point)
               bool modify = OrderModify(OrderTicket(), OrderOpenPrice(),Ask + TrailingStopStep* point, OrderTakeProfit(), 0, clrRed);                        
               }}}}}   
 

error 1 means that the EA try to modify order to a stop loss level of the same value. So, nothing happen.

It is actually not considered as an error. You need to check the new SL level calculation before modify the order.

If it has the same value or less than StopLevel value specified be the broker, just pass it.

If it is too important to keep the SL too tight, then you need to work on stealth mode. Which means you have

to consider that SL value but never modify the order. Once price changes then you may make your changes

accordingly as it was exist. It is more complicated code but not much as you could expect.