Advertisement IC Markets

Error 129 and the stale-tick bug in homemade EAs

Compare ECN/Raw spread brokers, analyze execution speeds, report slippage, and evaluate commission structures for high-frequency traders.
Post Reply
Amanhasnoname
Posts: 1506
Joined: Fri Oct 30, 2026 9:45 am

Error 129 and the stale-tick bug in homemade EAs

Post by Amanhasnoname »

Error 129, invalid price, usually points to a bug rather than a market event. The EA sends an order with a price that does not match the current market: a buy at a price that is not the current ask, or a price with the wrong number of digits.

The common source is reading price variables that are not refreshed. In MQL4, Bid and Ask hold the last known values, but inside a long calculation or after a sleep, they may be outdated. A market order sent with an old price gets rejected, or on instant execution accounts, requoted.

Digits are the other culprit. A symbol with five digits needs prices rounded to five decimals. Floating-point arithmetic can produce values like 1.085000000001, which is not valid. Normalizing the price before sending avoids the issue.

Resetting rates with the refresh function before each order, and normalizing every price, eliminates most 129 errors.

Seeing this error repeatedly is a sign that the code deserves a review rather than a retry loop.

Does the EA normalize and refresh prices before every order?
Recommended broker for automated trading & scalping IC Markets
Post Reply