for(int i=0; i<OrdersTotal(); i++) if(OrderSelect(BuyTicket, SELECT_BY_TICKET)==True)
Why are you looping using OrdersTotal() when you are modifying the same ticket number?
If there are n orders open, you will try to modify the same ticket n times!
Are you checking that the order has not already been modified?
You will get an error if you are trying to modify an order with the same values.
The SL was set at 200 pips
if(NormalizeDouble(Bid, 5) <= NormalizeDouble(y-1000*_Point, 5) && Total == 0 && Orders_Per_Day == False && Hour() > 0 && DayOfWeek() >= 1 && DayOfWeek() <= 5) { Print("SELL BIG"); SellTicket = OrderSend(Symbol(), OP_SELLLIMIT, lot, y, 0, y+2000*_Point, y-1000*_Point, NULL, Magic, 0, clrRed); }The order has still been modified according the my trading rule, which is moving the SL to Order Open Price upon reaching 80% profit. I just want to modify the order once, to get the order break even.
for(int i=0; i<OrdersTotal(); i++) if(OrderSelect(SellTicket, SELECT_BY_TICKET)==True) { if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL && OrdersTotal() == 1) { if(OrderProfit() >= lot*722*0.8 && OrderProfit() <= lot*722*1) { OrderModify(SellTicket, NormalizeDouble(OrderOpenPrice(), Digits), NormalizeDouble(y, Digits), NormalizeDouble(OrderTakeProfit(), Digits), 0, clrNONE); } } }
The value y is my Order Open Price
Are you checking that the order has not already been modified?
You will get an error if you are trying to modify an order with the same values.

- www.mql5.com
What I found out is the order was modified at 11:45 and TP at 13:14.
And I received the error at 13:12.
So, if that is what you meant before. If the order has been modified for the first time, in this case, at 11:45. And the EA attempts to modify again (with the same value) at 13:12. That's why I received Error 1 message right?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey Guys!
In my backtest result, the order was modified successfully by changing the SL at the Order Open Price upon reaching 80% of total profit (Break Even). However, I still received the OrderModify Error 1 message.
The TP value does not change, only changed the SL value. Still, getting the Error 1.