order modify return error code 1

 

Hi everyone I wan to change my stoploss everytime price moves more than numbers of points,

double stepInPoint = 20*Point();
double initialPrice = OrderOpenPrice();

void UpdateAllOpenOrders()
  {
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol())
           {
            double StopLossPrice = 0;
            double TakeProfitPrice = 0;
            double trailStopStep = 40*Point();

            if(OrderType() == OP_BUY )
              {
               if(Bid+spread>=initialPrice+stepInPoint)
                 {
                  initialPrice += stepInPoint;
                  StopLossPrice = NormalizeDouble((OrderStopLoss()+trailStopStep),Digits);
                  TakeProfitPrice = 0;
                 }
              }

            if(OrderType() == OP_SELL )
              {
               if(Ask-spread<=initialPrice-stepInPoint)
                 {
                  initialPrice -= stepInPoint;
                  StopLossPrice = NormalizeDouble((OrderStopLoss()-trailStopStep),Digits);
                  TakeProfitPrice = 0;
                 }
              }

            if(OrderModify(OrderTicket(),OrderOpenPrice(),StopLossPrice,OrderTakeProfit(),OrderExpiration()))
              {
               Print("Order modify successfully for ticket #", OrderTicket());
              }
            else
              {
               Print("Order failed to update with error: ", GetLastError());
              }
           }
        }
      else
        {
         Print("Failed to select the order: ", GetLastError());
        }
     }
  }

using code above resulting in error 1. Anyone can help me fix the code?

 
Luandre Ezra: using code above resulting in error 1. Anyone can help me fix the code?
  1. ERR_NO_RESULT
    You Server
    Change the SL to X It is at X!
    Change the SL to X It is at X!
    Change the SL to X You are insane
    Insanity: doing the same thing over and over again and expecting different results.
              Unknown
  2. Compute the new SL. Compare to the current. Modify only if you are moving it at least a tick. You are currently calling modify, whether you computed StopLossPrice or not.

 
William Roeder #:
  1. ERR_NO_RESULT
    You Server
    Change the SL to X It is at X!
    Change the SL to X It is at X!
    Change the SL to X You are insane
  2. Compute the new SL. Compare to the current. Modify only if you are moving it at least a tick.

Yes, thank you. I just realize that after looking about error code 1.