MT5 Invalid Stops (Error 10016): Cause and Fix
Short answer: MT5 retcode 10016 (TRADE_RETCODE_INVALID_STOPS, "Invalid
stops in the request") means the broker rejected the stop loss or take profit.
Usually the stop is closer to the current price than the symbol's minimum stop
distance (the stops level), on the wrong side of price, or not rounded to the
symbol's digits. The MT4 equivalent is error 130. Read the stops level from
the symbol and keep every stop outside it.
What does "invalid stops" mean?
Every symbol has a contract specification set by the broker. One of its values is
SYMBOL_TRADE_STOPS_LEVEL — the minimum distance, in points, between the current
price and any stop loss or take profit. Send a stop inside that distance and the
server refuses the whole request.
The five causes, in order of frequency
1. The stop is inside the stops level
A 50-point stop on a symbol with a 100-point stops level fails every time. Gold, indices and exotic pairs often have larger levels than majors — and brokers change them around news.
2. The stop is measured from the wrong price
A buy position closes at Bid, so its stop loss must be below Bid by at least the stops level — not below Ask. A sell closes at Ask, so its stop loss must be above Ask. Compute a buy's stop from Ask with a small distance, and when the spread is wide it can end up above Bid: instantly invalid.
| Position | Stop loss must be | Take profit must be |
|---|---|---|
| Buy | ≤ Bid − stops level | ≥ Bid + stops level |
| Sell | ≥ Ask + stops level | ≤ Ask − stops level |
3. Points and pips confused
On a 5-digit quote, 1 pip is 10 points. An EA that means "20 pips" and sends "20 points" places a 2-pip stop — almost always inside the stops level.
4. The price is not rounded
A stop must be a valid price for the symbol: NormalizeDouble(price, _Digits).
Arithmetic like ask - 0.0020 can leave a tiny remainder the server rejects.
5. The freeze level (when modifying)
Close to an existing stop or target, the broker may freeze the position against
changes — SYMBOL_TRADE_FREEZE_LEVEL. Modifications inside it are refused (retcode
10029, "frozen"). Trailing and break-even logic hits this most.
MQL5 code that keeps stops legal
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
int stops = (int)SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double minDist = (stops + 1) * point; // one point of headroom
// A buy with SlPoints / TpPoints inputs, measured from the entry (Ask)
double sl = NormalizeDouble(ask - SlPoints * point, digits);
double tp = NormalizeDouble(ask + TpPoints * point, digits);
if(bid - sl < minDist || tp - bid < minDist)
{
Print("Stops too close for this symbol: need ", stops, " points");
return; // or widen the stops deliberately — but decide, don't guess
}
Skipping the trade is usually better than silently widening the stop: a wider stop changes the risk you sized the position for.
A stops level of 0 means the broker sets no fixed minimum — but a stop inside the spread still fails, so keep the Bid/Ask rule above.
MT4: error 130
The same problem in MT4 is error 130 (ERR_INVALID_STOPS). The stops level comes
from MarketInfo(Symbol(), MODE_STOPLEVEL), and the same Bid/Ask rule applies.
Preventing it in a TradeSmithy graph
Stops on the BUY Order and SELL Order nodes are set in points — the unit the server checks — and the Symbol Info node reads Min stop distance (points) from the broker at runtime, so a graph can compare its stop against the real limit instead of a number you looked up once. The MQL generator is also instructed to respect the symbol's minimum stop distance. For volatile symbols, size stops from ATR so they sit well outside the limit anyway — see building an EA for gold.
Start free to build and export a strategy that reads its limits from the symbol; the AI assistant and server backtests are on Pro. For other reasons an EA stays silent, see why is my EA not trading?
Frequently asked questions
What is error 10016 in MT5?
TRADE_RETCODE_INVALID_STOPS: the stop loss or take profit in the request is
invalid — usually too close to price or on the wrong side.
How do I find the minimum stop distance for a symbol?
Right-click the symbol in Market Watch → Specification, and look at the stops
level — or read SYMBOL_TRADE_STOPS_LEVEL in code.
Why do I get invalid stops only sometimes?
The stops level or the spread changed — often around news or rollover — putting a normally valid stop inside the limit.
Is error 130 in MT4 the same as 10016 in MT5?
Yes, both mean invalid stops, with the same causes.
Keep reading
Fixing AI-Generated MQL5: The Compile Errors Models Make
The MetaEditor errors ChatGPT and Claude produce most often in MQL5 — what each message means, the MQL4 habit behind it, and the one-line fix.
5 min readWhy Is My EA Not Trading? A 12-Point MT5 and MT4 Checklist
The EA is attached, the market is moving, and nothing happens. Twelve causes in the order worth checking, with the MT5 and MT4 error codes that name each one.
4 min readHow to Convert an MT4 EA to MT5 (and Why Converters Fail)
An .ex4 will not run on MT5, and MQL4 is not a dialect of MQL5. What actually has to change, when a converter is enough, and what to do with no source code.
4 min read