The short answer
“Invalid stops” means your stop-loss or take-profit breaks one of three rules. It is on the wrong side of the price that would close your trade; it is closer than the stops level, the minimum distance your provider sets for gold; or the order is inside the freeze level, so it can’t be changed right now. MT4 shows this as error 130, MT5 as 10016, “Invalid stops in the request”.
The fix: move the level further away, measured from the bid for buys and the ask for sells, by more than the Stops level shown in gold’s Specification.
Why it happens: the exact rules
MetaQuotes publishes the rules. Buys open at the ask and close at the bid; sells open at the bid and close at the ask. Stops and targets are measured from the closing price:
| Order | Stop-loss rule | Take-profit rule |
|---|---|---|
| Buy (long) | Bid − SL ≥ StopLevel | TP − Bid ≥ StopLevel |
| Sell (short) | SL − Ask ≥ StopLevel | Ask − TP ≥ StopLevel |
| Buy limit | Open price − SL ≥ StopLevel | TP − Open price ≥ StopLevel |
| Sell limit | SL − Open price ≥ StopLevel | Open price − TP ≥ StopLevel |
| Buy stop | Open price − SL ≥ StopLevel | TP − Open price ≥ StopLevel |
| Sell stop | SL − Open price ≥ StopLevel | Open price − TP ≥ StopLevel |
Pending orders have their own entry rule: a buy limit must be at least the stops level below the ask, a sell limit above the bid, a buy stop above the ask and a sell stop below the bid. A pending order on the wrong side gives “invalid price” (MT4 129, MT5 10015) instead.
The freeze level works similarly but blocks changes: for a buy, you cannot modify if Bid − SL or TP − Bid is not greater than the freeze level; for a sell, the same with the ask. MT4 reports this as 145, “Modification denied because order is too close to market”; MT5 as 10029, “Order or position frozen”.
Points, pips and dollars on gold
The stops level is given in points, the smallest price step of the symbol. On gold, that depends on how many decimals your provider quotes:
| Gold quoted as | One point | Stops level 100 points | Stops level 50 points |
|---|---|---|---|
| 4000.25 (2 decimals) | $0.01 | $1.00 | $0.50 |
| 4000.253 (3 decimals) | $0.001 | $0.10 | $0.05 |
Many traders call $0.10 a pip on gold; our pip calculator explains the conventions. Mixing up points and pips is the most common cause of invalid stops in EAs.
A worked example (illustrative)
You sell 0.10 lot of XAUUSD. The bid is $4,000.00, the ask $4,000.30 (a $0.30 spread). Gold is quoted to 2 decimals and the Specification shows Stops level: 100, so the minimum distance is $1.00.
- Stop-loss: must satisfy SL − Ask ≥ $1.00, so SL ≥ $4,001.30. You typed $4,001.00, which is only $0.70 above the ask: invalid stops.
- Take-profit: must satisfy Ask − TP ≥ $1.00, so TP ≤ $3,999.30. A target at $3,999.50 would also be rejected.
Move the stop to $4,001.30 or beyond and it is accepted. Notice that the minimum distance is measured from the ask, not from the bid your chart shows, which is why a level that looks $1.00 away on the chart can still fail. With 0.10 lot, each $1 is worth $10, so a stop at $4,005.00 risks about $50 plus costs.
The spread matters too. If the spread widens to $1.50 at the daily break, the ask is $4,001.50 and your stop at $4,001.30 is now on the wrong side: you can’t place it at all until the spread narrows.
Exactly how to fix it, step by step
- Check the side. For a buy, SL below and TP above the bid. For a sell, SL above and TP below the ask.
- Turn on the ask line (right-click the chart → Properties (F8) → Show Ask line in MT4, Show Ask price line on the Show tab in MT5) so you can see the price sell orders are measured from.
- Open the Specification (right-click gold in Market Watch) and read Stops level and Freeze level, and note how many digits the price has.
- Convert to dollars using the table above and add a margin: the distance must exceed the stops level plus any spread widening you could meet.
- Retry with the wider level. If you need a tighter dollar risk, reduce the lot size instead; the position size calculator does it in seconds.
- If modification is refused near price (145 / 10029), wait until price moves away from your level, or close the trade manually.
- On market-execution MT4 accounts, if an order with SL/TP attached is rejected, open it without them and add the stop and target immediately with Modify. Many EAs do this in two steps for that reason.
Notes for EA users
- Read
MODE_STOPLEVELandMODE_FREEZELEVELwithMarketInfo()in MT4, orSYMBOL_TRADE_STOPS_LEVELandSYMBOL_TRADE_FREEZE_LEVELwithSymbolInfoInteger()in MT5, rather than hard-coding a distance. - Multiply by
Point/_Point, not by a fixed 0.01 or 0.1, so the EA works whatever the digits. - Normalise every price with
NormalizeDouble(price, Digits)(MT4) or_Digits(MT5). - Measure sell stops from the Ask, buy stops from the Bid.
- The full list of codes is in our MT4 and MT5 error codes reference.
How to avoid it from now on
- Keep stops at a volatility-based distance: the ATR stop-loss calculator usually puts gold stops far beyond any stops level.
- Don’t set or move stops in the minutes around the 5 pm New York break or big releases, when spreads are widest.
- Write your symbol’s stops level, freeze level and digits in your trading plan.
For setting stops on a phone, see how to set stop-loss and take-profit on gold in MT5; for other errors, MT5 gold errors explained and gold trading problems solved.
Sources
- MetaQuotes, MQL4 book: Requirements and limitations in making trades (StopLevel and FreezeLevel rules)
- MetaQuotes, MQL4 documentation: Error codes (130, 129, 145)
- MetaQuotes, MQL5 documentation: Trade server return codes (10015, 10016, 10029)
- Prices, spreads and stops levels in the example are hypothetical
Educational content only, not financial advice. Stops levels and execution types vary by provider. Trading gold with leverage carries a high risk of loss.
Frequently asked questions
What does 'invalid stops' mean on gold?
Your stop-loss or take-profit breaks one of the platform’s rules: it is on the wrong side of the current price, it is closer to the price than the symbol’s minimum distance (the stops level), or the trade is inside the freeze level and can’t be modified. MT4 reports it as error 130, MT5 as 10016 ‘Invalid stops in the request’.
What is the stops level on XAUUSD?
It is the minimum distance, in points, between the current price and a stop-loss, take-profit or pending order, set by your provider for that symbol. You can see it in the symbol’s Specification as Stops level. On a gold symbol quoted to two decimals, one point is $0.01, so a stops level of 100 means $1.00. A value of 0 means no fixed minimum, but the levels must still be on the correct side of the price.
Which price is my stop compared with?
The price that would close the trade. A buy (long) is closed at the bid, so its stop-loss must be below the bid and its take-profit above it by at least the stops level. A sell (short) is closed at the ask, so its stop-loss must be above the ask and its take-profit below it.
Why does my EA get error 130 when I can set the same stop by hand?
Common reasons: the EA calculates the distance in points but the symbol has a different number of digits than it assumes, it uses Bid where it should use Ask (or the reverse), it doesn’t normalise prices to the symbol’s digits, or the account uses market execution and wants stops added after the order is filled. Read the stops level and digits from the symbol in code.
What is the freeze level?
A second distance, in points, inside which the provider will not let you modify or delete orders because price is about to reach them. If price is within the freeze level of your stop, take-profit or pending order, a modification is refused until price moves away.
Comments
No comments yet.