Error Code 1 with OrderModify

 

Hello,


What does Error Code 1 means, i am getting this while order Modification.


extern double Trailing_Gap = 3.0;
extern double Trailing_TP = 30.0;

   if(Digits == 3 || Digits == 5)
      Pips = 10.0 * Point;
   else
      Pips = Point;

void TrailingStopLoss(int TrailingStopLoss_magic)
  {
// Loop through all open orders
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         double TrailingStopLoss_entryPrice = OrderOpenPrice();


         // Buy Order Modification
         if(OrderMagicNumber() == TrailingStopLoss_magic && OrderType() == OP_BUY)
           {

            if(Bid - (TrailingStopLoss_entryPrice + Trailing_TP * Pips) > Pips * Trailing_Gap)
              {
               if(OrderStopLoss() < Bid - Pips * Trailing_Gap)
                 {
                  OrderModify(OrderTicket(), TrailingStopLoss_entryPrice + Trailing_TP * Pips, Bid - Pips * Trailing_Gap, OrderTakeProfit(), 0, clrNONE);
                  Print("Trailing Buy Error :" + GetLastError());
                 }
              }
           }

         // Sell Order Modification
         if(OrderMagicNumber() == TrailingStopLoss_magic && OrderType() == OP_SELL)
           {

            if((TrailingStopLoss_entryPrice - Trailing_TP * Pips) - Ask > Pips * Trailing_Gap)
              {
               if(OrderStopLoss() > Ask + Pips * Trailing_Gap || OrderStopLoss() == 0.0)
                 {

                  OrderModify(OrderTicket(), TrailingStopLoss_entryPrice - Trailing_TP * Pips, Ask + Pips * Trailing_Gap, OrderTakeProfit(), 0, clrNONE);
                  Print("Trailing Sell Error :" + GetLastError());

                 }
              }
           }
        }
     }
  }
 
anuj71: What does Error Code 1 means,

If you had used this, you would have found many threads: 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

Compute the new value, then check that you are moving the existing value at least a tick (in the currect direction).
          What is a TICK? - MQL4 programming forum (2014)

 
William Roeder #:

If you had used this, you would have found many threads: 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

Compute the new value, then check that you are moving the existing value at least a tick (in the currect direction).
          What is a TICK? - MQL4 programming forum (2014)

Thanks for the response, and I also searched :). I understand that this is happening due to the same value passing into OrderModify. However, I am now unable to understand why it keeps pushing the same value again and again. I reviewed my TrailingStopLoss (OrderModify) code again, but I haven't found the reason behind passing the same value repeatedly. Could you please take a look at the code, which I posted above in this thread? If you can give me an idea of why and what is causing this, I would appreciate it.

 
anuj71 #: , I am now unable to understand why it keeps pushing the same value again and again.
            if((TrailingStopLoss_entryPrice - Trailing_TP * Pips) - Ask > Pips * Trailing_Gap)

Doubles are rarely equal; your comparison will usually be true. Understand the links in:
          The == operand. - MQL4 programming forum #2 (2013)

What part of “check that you are moving the existing value at least a tick” was unclear?

Reason: