# Can't avoid OrderModify error 1, even if parameters change! - page 2

23

I'd like to share the solution to this topic.

In my case, OrderModify error 1 was due to a hidden problem in the condition if(valEntry != OrderOpenPrice()). This two values sometimes were different, even though visibly (up to the 5th digit) they were not.

The solution consists in normalizing them up to the 5th digit. Hope it could help!

(The same solution can be applied to the most common TrailingStop function, when OrderModify error 1 occurs).

```void TrailingPendingOrder()

{
double valEntry, valSL, valTP;

//BuyStop
valEntry = Ask + pipsPendingDist*Point*P;
valSL = Bid + pipsPendingDist*Point*P - pipsPendingSL*Point*P;
valTP = Bid + pipsPendingDist*Point*P + pipsPendingTP*Point*P;

if(OrderSelect(ticket[0],SELECT_BY_TICKET) && NormalizeDouble(valEntry, 5) != NormalizeDouble(OrderOpenPrice(), 5)){
if(!OrderModify(ticket[0], valEntry, valSL, valTP, 0, clrYellow)){
Print("Error TPO for Buy #", GetLastError());
}
}

//SellStop
valEntry = Bid - pipsPendingDist*Point*P;
valSL = Ask - pipsPendingDist*Point*P + pipsPendingSL*Point*P;
valTP = Ask - pipsPendingDist*Point*P - pipsPendingTP*Point*P;

if(OrderSelect(ticket[1],SELECT_BY_TICKET) && NormalizeDouble(valEntry, 5) != NormalizeDouble(OrderOpenPrice(), 5)){
if(!OrderModify(ticket[1], valEntry, valSL, valTP, 0, clrYellow)){
Print("Error TPO for Sell #", GetLastError());
}
}
}```
To add comments, please log in or register