Order Modify error 1

 

This code gives me the occasional order modify error 1. It seems like the code checks that the stop isn;t the same so not sure why the error occurs;


      if (TrailingStop >0)
      {
         int totaltrail = OrdersTotal();
         for(int itrail=totaltrail-1;itrail>=0;itrail--)
         {
            if( OrderSelect(itrail,SELECT_BY_POS) && OrderCloseTime()==0 )
            {
               if( ( OrderType()==OP_BUY ) && 
                  ((Bid-OrderOpenPrice()) > Point*TrailingStop) &&
                  (OrderStopLoss()<(Bid-Point*TrailingStop))
               )
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,NULL,0);
               }
               else if( ( OrderType()==OP_SELL ) && 
                        ((OrderOpenPrice()-Ask) > Point*TrailingStop) &&
                        (OrderStopLoss()>(Ask+Point*TrailingStop))
                     )
               {
                  OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,NULL,0);
               } 
               
            }
      
         }
      }
 
Replace
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,NULL,0);
to
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),NULL,0);
Reason: