MT4 error 4107: Invalid price parameter for trade function (ERR_INVALID_PRICE_PARAM)
The terminal refused the price you passed to a trade function, often because it isn't normalized. Nothing was sent.
What it means
You see this code in GetLastError() in MQL4, raised inside the terminal.
4107 comes from the terminal, before the request leaves. The price argument isn't valid as written.
It is close to server error 129, but caught earlier.
Common causes
- A price with more decimals than the symbol's
Digits. - A price of 0 or a negative price.
- A price for another symbol, read from
AskorBidof the chart symbol.
How to fix it
- Normalize every price with
NormalizeDouble(price, Digits). - For another symbol, read its price and digits with
MarketInfo().
Example in MQL4:
string sym = "USDJPY";
int dg = (int)MarketInfo(sym, MODE_DIGITS);
double bid = NormalizeDouble(MarketInfo(sym, MODE_BID), dg);
double sl = NormalizeDouble(bid + 0.30, dg);
int ticket = OrderSend(sym, OP_SELL, 0.10, bid, 3, sl, 0, "", 4711); Is it safe to retry?
After a fix. With a valid, normalized price.
Could the order have executed?
No. The terminal rejected the price argument before sending anything.
How Tickwire handles it
Tickwire treats it like MT5 10015, and the MT4 code stays in the message. See trade results.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.