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

Back to topics list To post a new topic, please log in or register
avatar
273
sheriffonline 2015.10.02 16:40
 
 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?

avatar
12983
WHRoeder 2015.10.02 18:05 #
 
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

avatar
273
sheriffonline 2015.10.02 18:26 #
 
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.
avatar
7
pije76 2016.03.21 07:36 #
 
sheriffonline:
Yes. Fixed already. Thanks WHRoeder.
Hi sheriffonline, can you share your solution please?
avatar
12983
WHRoeder 2016.03.21 13:13 #
 
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(...
   :

Back to topics list  

To add comments, please log in or register