Your MT5 EA hit Invalid Stops: build a reproducible preflight test

Diagnose MT5 stop-distance rejections without guessing. A log-only test for Stops Level, Freeze Level, quote references and retcodes before an EA sends an order.

BamaUp Editorial ·
A red stop-sign vector illustrating an invalid stop-level preflight test, not a trading result or price chart
Stop Sign.svg by FoxkehFan2328, via Wikimedia Commons, CC0 1.0, unmodified. Conceptual illustration.

A rejected stop is a test case, not a market opinion

An Expert Advisor may run its signal logic correctly and still fail when it tries to place or modify a protective level. In MetaTrader 5, a server return code is more useful than an anecdote about a 'bad broker'. The published MQL5 codes distinguish TRADE_RETCODE_INVALID_STOPS (10016) from TRADE_RETCODE_FROZEN (10029) [4]. The first identifies an invalid stops request; the second signals that an order or position is frozen. The difference should be preserved in your test journal.

Do not assume the same explanation applies to market entry, a pending order, a Stop Loss modification and a Take Profit modification. Record the operation type, the side of the market, the exact proposed level and the server result. If you cannot reproduce the inputs that led to a rejection, you cannot reliably decide whether a new parameter setting fixed the problem.

Ask the symbol for its rules, not yesterday's screenshot

MetaQuotes lists SYMBOL_TRADE_STOPS_LEVEL as a minimum stop distance in points and SYMBOL_TRADE_FREEZE_LEVEL as the point distance associated with freezing certain trade operations [1]. These are distinct instrument properties exposed through SymbolInfoInteger [2]. They are not a universal fixed pip value, and the exact restrictions can depend on the symbol, account, broker and request type. Query the actual instrument you intend to test.

The price scale matters. A point is defined by the symbol's SYMBOL_POINT property; you should not copy a distance expressed as pips from another instrument or apply an assumed decimal scale. Snapshot the bid and ask at the same time as the symbol properties, noting which quote side is relevant to the proposed operation. A single unsynchronized field can turn a careful-looking spreadsheet into an invalid comparison.

Worked arithmetic with invented prices

Here is an explicitly hypothetical instrument. One point equals 0.0001, bid is 1.0000 and ask is 1.0002. Assume, strictly for illustration, that the stop-distance requirement for a proposed buy Stop Loss is 20 points relative to the relevant bid. A stop at 0.9985 is 15 points below 1.0000, so it falls short of the invented requirement. A stop at 0.9975 is 25 points away. This arithmetic illustrates a preflight comparison; it does not predict server acceptance or justify taking more risk.

Now imagine an independent 10-point freeze level and an attempted modification very close to the market. That test belongs in a different case from the initial stop-distance check. The actual freeze behavior is operation-specific, and the observed retcode, not a simplified illustration, remains your evidence. Never solve a validation failure by silently widening a live protective stop. Changing stop distance changes potential loss and can invalidate the original position size.

Build a log-only test matrix

Start with order submission disabled. Capture the timestamp, symbol, broker environment, bid, ask, point size, Stops Level, Freeze Level, order type, existing state, proposed protective price and expected allow/skip decision. Include a reason code when the test declines to evaluate a case. This record is also useful when an EA runs on multiple symbols or when a developer and a reviewer use different terminal settings.

Write the expected decisions before running the logic. Include below-threshold distances, clearly above-threshold distances, a near-freeze modification, missing symbol properties and a stale quote. If Market Watch does not include a symbol, SymbolInfoInteger can fail with a specific error [2]. Treat missing data as a failed precondition, not as evidence that trading restrictions have disappeared. Test buy and sell cases separately, because relevant reference prices and order rules may differ.

A basic request check cannot promise a fill

OrderCheck accepts a proposed MqlTradeRequest and returns details through MqlTradeCheckResult. Its documentation explicitly warns that success of the basic check does not guarantee successful execution [3]. Similarly, OrderSend returning true is not in itself proof of a completed trade: its result structure and return code still require inspection [5]. An engineering report should not collapse 'preflight accepted', 'request accepted' and 'deal completed' into one green label.

For this exercise, keep the evaluation entirely in the log-only stage and do not enable AutoTrading. Once an organization has a separately approved demo execution procedure, it can compare later server outcomes with the preflight expectations, but those are distinct experiments. Report rejects and unknown states alongside passes so the dataset does not become a carefully selected success story.

Turn a mysterious failure into a purchase decision

Before purchasing an EA or paying for an audit, ask whether the supplied evidence includes the exact symbol settings, sample failure logs, an identifiable program version and independent demo cases. If the seller only offers an equity curve, execution rejections remain unmeasured. An EX5 binary may permit observable behavioral tests, but it does not provide a complete source-code audit; source inspection requires MQ5 and related dependencies.

The next practical step is to run a twelve-row synthetic stop-level worksheet and retain each expected decision, calculated distance and actual filter output. Readers with an existing EA can explore BamaUp's audit service after identifying the unanswered questions, with scope and pricing confirmed before any purchase. No trading signal, return guarantee, verified performance history or live-order result is implied by this article.

Article references

1. Official MQL5 Reference: MQL5 Symbol Properties2. Official MQL5 Reference: MQL5 SymbolInfoInteger3. Official MQL5 Reference: MQL5 OrderCheck4. Official MQL5 Reference: MQL5 Trade Server Return Codes5. Official MQL5 Reference: MQL5 OrderSend

Hypothetical examples are not BamaUp trading performance.

Support