OrderModify error 1 and OrderModify() error - no error, trade conditions not changed

 
 for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
        {
            double SL = NormalizeDouble(OrderOpenPrice(), NDigits);
            double TP = NormalizeDouble(0, NDigits);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, White);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }

I change stoploss as breakeven once the price moves +20pips

why should i get the error while backtesting?

 
sheriffonline:

I change stoploss as breakeven once the price moves +20pips

why should i get the error while backtesting?

Because you already did.
You
Server
Change the SL to X
It is at X!
Change the SL to XIt is at X!
Change the SL to XYou are insane
 
WHRoeder:
sheriffonline:

I change stoploss as breakeven once the price moves +20pips

why should i get the error while backtesting?

Because you already did.
You
Server
Change the SL to X
It is at X!
Change the SL to XIt is at X!
Change the SL to XYou are insane

Yes. Fixed already. Thanks WHRoeder.
 
sheriffonline:
Yes. Fixed already. Thanks WHRoeder.
Hi sheriffonline, can you share your solution please?
 
pije76: Hi sheriffonline, can you share your solution please?
When in doubt, think.
double SL = ...;
double TP = ...;
if(MathAbs(OrderStopLoss()   - SL) > _Point   // Something is
|| MathAbs(OrderTakeProfit() - TP) > _Point){ // different.  
   bool ret = OrderModify(...
   :
 
whroeder1:
When in doubt, think.

I have a similar situation with this code:

void SellOrderModify1()
{
    for (int i=OrdersTotal()-1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == SellID)
        {
             double price= OrderOpenPrice();
             if (Bid< QTakeprofit_1)price=QTakeprofit_2;{

            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(),price, OrderTakeProfit(), 0, White);
            if (ret == false) Print("OrderModify() error - ", ErrorDescription(GetLastError()));}
        }
    }
    
}

QTakeProfit is the pair quote value, like 1.30220

If the Bid is bigger than QTakeProfit_1, (Something changed) and

will modify the order to set a new OrderStopLoss() = QTakeProfit_2.

But never get rid of the same error-

OrderModify() error - no error, trade conditions not changed
Maybe I missing something. Thank you in advance for the correction.
 
Sherif Hasan:

I change stoploss as breakeven once the price moves +20pips

why should i get the error while backtesting?

for (int i=OrdersTotal()-1; i >= 0; i--)
  {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
        {
           if(MarketInfo(Symbol(),MODE_BID)<OrderOpenPrice()-200*Point)
            {
            //double SL = NormalizeDouble(OrderOpenPrice(), NDigits);
            //double TP = NormalizeDouble(0, NDigits);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(),OrderTakeProfit(), 0, White);
            if (GetLastError()>0) Print("OrderModify() error - ", ErrorDescription(GetLastError()));
            }
        }
        }
Reason: