You're reading...
EA development, MQL5, Uncategorized

MQL5: [Invalid price] error on OrderModify

There’s a few things that could give the Invalid Prices error from OrderModify.

1. If you are trying to modify price, SL, TP, with the same values as before.

2. If you are trading on an asset which tick size is not the same as the smallest increment of the least significant value, e.g. Nikkei 225 mini futures increments by 5, e.g. 16830 -> 16835. NormalizeDouble(calculated_value, Digits()) may return 16818, which is not a valid price to change SL or TP to. You’ll have to round to a valid price, e.g.

double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
double roundedValue = MathRound(calculatedValue / tickSize) * tickSize; //you may want to round up or down according to your needs
Advertisements

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Archives

Visitors

Flag Counter
Advertisements
%d bloggers like this: