Trailing Stop OrderModify error 1

 

Dear !

I tried to fix my trailing stop function but i really don't know how to make logic without error  "OrderModify error 1".I hope someone can help.

for (int j = 0; j < Total; j ++) {
      
      if(OrderSelect(j, SELECT_BY_POS, MODE_TRADES)==false) continue;
      if(OrderSymbol() == Symbol() && OrderMagicNumber()==MagicNumber) {
        
         //Trailing stop        
         if(OrderType() == OP_BUY) {
              
            if(MarketInfo(Symbol(), MODE_BID) - OrderOpenPrice() > Point * Trailingstop) {
               if(OrderStopLoss() < MarketInfo(Symbol(), MODE_BID) - Point * Trailingstop) {
                  ticket = OrderModify(OrderTicket(), OrderOpenPrice(), MarketInfo(Symbol(), MODE_BID) - Point * Trailingstop, OrderTakeProfit(), 0, Blue);
               }
            }
               
         } 
         else {
            if(OrderType()==OP_SELL){
              
               if((OrderOpenPrice() - MarketInfo(Symbol(), MODE_ASK)) > (Point * Trailingstop)) {
                  if((OrderStopLoss() > (MarketInfo(Symbol(), MODE_ASK) + Point * Trailingstop)) || (OrderStopLoss() == 0)) {
                     ticket = OrderModify(OrderTicket(), OrderOpenPrice(), MarketInfo(Symbol(), MODE_ASK) + Point * Trailingstop, OrderTakeProfit(), 0, Red);
                  }
               }
                  
            }
         }  
      }
    }

 Thank you very much !

 
for(int j=0; j<Total; j++)
  {
   bool Select=OrderSelect(j,SELECT_BY_POS,MODE_TRADES);
     {
      if(Select>0)
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
           {        
            if(OrderType()==OP_BUY)
              {
               if(MarketInfo(OrderSymbol(),MODE_BID)-OrderOpenPrice()>MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop)
                 {
                  if(OrderStopLoss()<MarketInfo(OrderSymbol(),MODE_BID)-MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop)
                    {
                     ticket=OrderModify(OrderTicket(),OrderOpenPrice(),MarketInfo(OrderSymbol(),MODE_BID)-
                     MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop,OrderTakeProfit(),0,Blue);
                    }
                 }
              }
            else
              {
               if(OrderType()==OP_SELL)
                 {
                  if((OrderOpenPrice()-MarketInfo(OrderSymbol(),MODE_ASK))>(MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop))
                    {
                     if((OrderStopLoss()>(MarketInfo(OrderSymbol(),MODE_ASK)+MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop)) || (OrderStopLoss()==0))
                       {
                        ticket=OrderModify(OrderTicket(),OrderOpenPrice(),MarketInfo(OrderSymbol(),MODE_ASK)+
                        MarketInfo(OrderSymbol(), MODE_POINT)*Trailingstop,OrderTakeProfit(),0,Red);
                       }
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
 

NOrmally, OrderModify error 1 is not considered as an error because it means that the EA trying to modify the price to the same price.

You just need to check just before the OrderModify() function what is the new price to modify to ... if it is the same price, then just pass it.

 

OrderModify error 1

 

Still got this error