AlgoPuzzle Open the Builder
← Back to all articles

Platforms

Invalid Stops Error (130 / 10016): Why Your EA's Stop Loss Gets Rejected

An "invalid stops" error means the broker's server rejected the stop loss or take profit attached to an order - MetaTrader 4 reports it as error 130, and MetaTrader 5 as retcode 10016 (TRADE_RETCODE_INVALID_STOPS). In most cases it comes down to one of five causes: the stop sits closer to the current price than the symbol's minimum stop level allows, the stop is on the wrong side of the price for the trade direction, a pips-versus-points mix-up or an unrounded price, a distance measured from the wrong side of the spread, or an order being modified while price is inside the freeze level. Each of those is fixable in the strategy's logic, and the table below lists the fix for every one. A smaller number of cases has no visible cause at all: the symbol's stop level reads zero, the distances are generous, the prices are correct - and the broker still rejects the order. For those, the practical workaround is to stop asking the server to hold the stop and have the EA enforce it itself, which comes with real trade-offs covered further down.

The five usual causes, and the fix for each

CauseWhat is going wrongFix
1. Below the minimum stop levelThe stop is closer to the current price than the symbol's stop level (SYMBOL_TRADE_STOPS_LEVEL in MQL5, MODE_STOPLEVEL in MQL4), which is reported in pointsRead the stop level at runtime and keep every stop at least that far away, with a small buffer for spread changes
2. Wrong side of the priceA buy needs its stop loss below the price and its take profit above; a sell is the reverse. A flipped sign or an inverted formula puts one on the wrong sideCheck the sign of every distance calculation for both directions
3. Pips vs. points, or an unrounded priceOn a 5-digit forex symbol one pip is ten points, so a "20 pip" stop typed in as 20 points is really 2 pips - inside the stop level. Prices not rounded to the symbol's digits get rejected tooConvert pips to price distance using the symbol's own digits, then normalize every price before sending
4. Measured from the wrong side of the spreadStop distances are checked against the price the position would close at: Bid for a buy, Ask for a sell. Measuring from the entry-side price shifts the stop by the full spreadAnchor the stop to the exit-side price for the trade direction
5. Modifying inside the freeze levelWhile price is within the symbol's freeze level (SYMBOL_TRADE_FREEZE_LEVEL) of an order or stop, the server refuses modificationsSkip the modification and retry on a later tick instead of forcing it

Why a stop level of zero does not mean "anything goes"

A stop level of 0 usually means the broker publishes no fixed minimum distance, not that every distance will be accepted. Some brokers apply a floating minimum that widens around news or thin liquidity, and some enforce rules on the server that never show up in the symbol's properties. That is why an EA can pass every check above on one broker and still be rejected on another using identical code.

When every check passes and it still fails

Some broker and account combinations reject an order that carries a stop loss or take profit even when the distances are legitimate, or accept the order only when it is opened without stops and modified afterward. Opening first and modifying second is a known pattern on market-execution accounts, but it is not universal - there are setups where the modification is rejected with the same error too. When both routes fail, the remaining option is to keep the stop out of the server's hands entirely: the EA watches the live price on every tick and closes the position itself the moment the level is crossed.

Server-side stops vs. EA-managed stops

Server-side stopEA-managed ("virtual") stop
Who enforces itThe broker's serverThe EA, checking price on every tick
Can trigger invalid stops errorsYesNo - nothing is sent to the server until the close
Still works if the terminal or VPS goes offlineYesNo - nothing is watching the price
Visible in the platform's position listYesNo - the SL/TP column stays empty
Exit priceFilled by the server at the stopA market close after the level is crossed, so slippage applies

Neither approach is strictly better. Server-side stops survive a dropped connection; EA-managed stops survive a broker that rejects them. Every EA and cBot AlgoPuzzle exports - MT5, MT4, and cTrader - uses the EA-managed design, so it does not depend on a broker accepting attached stops. The consequence to plan for: the EA has to stay running, so a VPS is worth it for anything left unattended, and the empty SL/TP column in the position list is expected rather than a bug. See stop loss vs. take profit for how the two levels work together and MT4 vs. MT5 vs. cTrader for how each platform handles automation.

Common questions

What does invalid stops error 130 mean in MT4?

Error 130 (ERR_INVALID_STOPS) means the broker's server rejected the stop loss or take profit on an order or modification. The usual reasons are a stop placed closer to the current price than the symbol's minimum stop level allows, a stop on the wrong side of the price for the trade direction, or a price that isn't rounded to the symbol's number of digits.

What is retcode 10016 in MT5?

Retcode 10016 is TRADE_RETCODE_INVALID_STOPS - the MT5 equivalent of MT4's error 130. The trade server rejected the order because its stop loss or take profit levels were not acceptable, typically for the same reasons: distance below the stop level, wrong side of price, or unnormalized price values.

How do I find my broker's minimum stop distance?

Read the symbol's stop level - SYMBOL_TRADE_STOPS_LEVEL in MQL5 or MODE_STOPLEVEL in MQL4 - which is reported in points, not pips. On most brokers a 5-digit symbol has 10 points per pip, so a stop level of 30 points is 3 pips. A value of 0 usually means there is no fixed minimum, not that every distance is guaranteed to be accepted.

Why does the broker reject my stop loss even when the distance is correct?

Some brokers and account types reject server-side stops for reasons the symbol properties don't explain, or require an order to be opened without a stop and modified afterward. When every check passes and the error persists, the workaround is to have the EA monitor price itself and close the position when the level is crossed, instead of asking the server to hold the stop.

Build an EA that skips the stop-level problem - Free