Your EA Found a Perfect Trade. MT5 Said "Invalid Stops" (10016).
Imagine the scene.
Your Expert Advisor has been watching the chart for hours. It finally spots a setup. You lean toward the screen, mentally congratulating your robot on its excellent timing.
Then MetaTrader 5 replies:
Invalid stops. Error 10016.
Well, that was a short celebration.
The robot found an opportunity. The trading server found a problem. And now both are staring at each other like two drivers who have reached a one-lane bridge.
Before you fire your EA, widen every stop loss, or announce that your broker has declared war on you, here's what that message actually tells us.
Your strategy might be fine. Your trade request might not be.
In MT5, trade-server return code 10016 means "invalid stops in the request."
In ordinary language, the server rejected a stop-related price in the trade request. That could concern a stop loss, a take profit, or a pending-order price.
It does not prove that the EA's trading idea was wrong. It tells you that this particular request didn't satisfy the server's trading rules.
Think of it like trying to park in an otherwise perfectly good street. The car works. The road works. But the painted line says, "Not there, please."
So what line did the EA cross?
Meet the broker's invisible measuring tape
Every trading symbol has specifications. Some include a minimum distance for stop-related prices, known as the Stops level.
In MT5:
- Open Market Watch.
- Right-click the exact symbol your EA trades.
- Choose Specification.
- Look at the Stops level, Digits and other trading details.
That exact symbol part matters. XAUUSD, XAUUSDm and GOLD might look like relatives at a family reunion, but their contract details and trading restrictions can differ. One broker's Gold settings do not automatically apply to another's.
The Stops level is expressed in points, not automatically in dollars or pips. Digits and point size tell you how those points translate into a price distance. A symbol's Tick size, the permitted price increment, can also matter.
And there's a catch that makes many EA developers sigh: being on the correct side of the market isn't enough if your stop is still too close.
The little Bid/Ask trap
Let's use a fictional Gold example, purely to understand the maths. These are not live prices or advice for placing a stop.
Suppose your broker shows:
- Bid: 2500.00
- Ask: 2500.20
- Point size: 0.01
- Stops level: 50 points, meaning a price distance of 0.50
Now imagine an existing BUY position. Your EA tries to move its stop loss to 2499.70.
"That's below the market," the EA might argue.
True. But the relevant closing-side quote for a Buy position is generally the Bid, not the Ask.
2500.00 minus 2499.70 is 0.30.
The required distance in this example is 0.50.
The server's response? Your stop is too close. Cue error 10016.
A level such as 2499.40 would be farther away than that one minimum distance. But please don't interpret that as a recommended stop price or a promise that the request will succeed. You must still consider tick increments, changing quotes, other symbol rules and, most importantly, the trading strategy's intended risk.
For an existing SELL position, the relevant closing-side quote is generally the Ask. Checking a sell stop against the Bid can create the same mistake in reverse.
The Bid and Ask aren't interchangeable twins. They're more like siblings who insist on sitting on different sides of the table.
"But it worked in the backtest!"
A familiar sentence. Sometimes followed by a long silence.
Suppose an EA calculates a stop using the latest quote. In that moment, the distance appears valid. Then the market moves before the server processes the modification.
By the time the request arrives, the same stop might be too close.
Fast markets and changing spreads can make this more noticeable, particularly on Gold. A quick VPS may help with some delays, but it doesn't make prices stand still or cancel server-side checks.
This is one reason a historical test and live trading can behave differently. Neither the tester nor the robot can guarantee tomorrow's exact quotes and execution conditions.
Another plot twist: perhaps it's not 10016 at all
Not every order failure is an invalid-stop problem. MT5 gives us different return codes for different failures:
- 10016: Invalid stops in the request.
- 10015: Invalid price in the request.
- 10029: Order or position frozen.
- 10030: Invalid order filling type.
If the EA is trailing a stop or moving it to break-even, also investigate the symbol's Freeze level. That's a separate trading restriction affecting certain order or position operations.
And be careful with the terminal's own error messages. A message saying a request failed is not enough to establish which trade-server return code caused it.
In other words, before treating every red message like the same villain, read the name tag.
Five things to check before changing your EA
Here is a practical troubleshooting routine for a demo account:
- Find the actual failure. Check the MT5 Experts and Journal tabs. Note the time, symbol, operation and exact server response.
- Capture the requested prices. Was the EA opening a new position, placing a pending order, or modifying an existing stop? Write down the order type and the entry, SL and TP prices if available.
- Read the symbol rules. Check Stops level, Digits, Tick size and any relevant Freeze level for the exact broker symbol.
- Do the right comparison. For an existing Buy position, check stop placement against the Bid; for an existing Sell, against the Ask. Apply the correct rules for pending-order placement separately.
- Change one thing, then verify. Test a risk-consistent correction, observe the actual server result, and check whether an order or position was created.
That last point is important. Don't blindly resend a trade because you saw an error. First check whether the original request created an order or position. A second unintended trade is an expensive way to discover your logging was incomplete.
Developers can use OrderCheck() as part of request validation, but a successful preliminary check is not a guarantee of execution. The server's final return code still matters.
The tempting shortcut you should question
"Fine. I'll just remove the stop loss."
That's not a technical fix. That's replacing one problem with a potentially larger one.
Likewise, automatically widening every stop to satisfy the broker can materially change the intended risk. A strategy that needed one particular stop distance may no longer make sense with a different one.
If the only way to force the trade through is to abandon the original risk limit, skipping that trade might be the sensible result.
Nobody enjoys a rejected order. But sometimes the most useful thing an error message does is stop us from solving the wrong problem.
Error 10016 doesn't tell you to argue with the broker, blame your EA or delete your risk controls. It tells you to inspect the request.
Read the log. Measure the distance. Check the right quote. Respect the trading rules.
Your trading robot can do the clicking. You still have to do the thinking.
This article is educational. The Gold prices and stop levels are hypothetical. Trading and automated strategies involve risk, and no particular outcome is guaranteed.


