Download MetaTrader 5

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

To add comments, please log in or register
Sherif Hasan
7308
Sherif Hasan  
 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?

whroeder1
15017
whroeder1  
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
Sherif Hasan
7308
Sherif Hasan  
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.
Panjianom Adi Pratomo
298
Panjianom Adi Pratomo  
sheriffonline:
Yes. Fixed already. Thanks WHRoeder.
Hi sheriffonline, can you share your solution please?
whroeder1
15017
whroeder1  
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(...
   :
To add comments, please log in or register