Download MetaTrader 5
To add comments, please log in or register
Have you discovered something really important? Write an article and receive 200 USD!
Sherif Hasan
7224
Sherif Hasan 2015.10.02 14: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?

whroeder1
13656
whroeder1 2015.10.02 16: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
Sherif Hasan
7224
Sherif Hasan 2015.10.02 16: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.
Panjianom Adi Pratomo
228
Panjianom Adi Pratomo 2016.03.21 06:36  
sheriffonline:
Yes. Fixed already. Thanks WHRoeder.
Hi sheriffonline, can you share your solution please?
whroeder1
13656
whroeder1 2016.03.21 12: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(...
   :
/
To add comments, please log in or register