The Stop Loss Maths
$10,000 account, 100-trade simulation across 3 stop loss approaches
No Stop Loss
97 trades at +$50 each. 3 gap/spike events at โ$2,000 each (rare but inevitable on gold). Net loss despite a 97% win rate.
Stop Loss Too Tight (5 pips)
Win rate drops to 35% because market noise on M15 XAUUSD is typically 10โ20 pips. Most wins are cut short before price can move. Barely positive โ and this is the optimistic version.
ATR-Based Stop (20โ30 pips)
Win rate 55% with 1:1.5 R:R. SL is wide enough to avoid noise but tight enough to contain losses. Net positive, drawdown is controlled, and no catastrophic loss risk.
Should Your Gold EA
Use a Stop Loss?
Published 15 June 2026 ยท 12 min read
Yes โ every gold EA trade should have a hard stop loss. No-SL strategies look strong in backtests because they avoid recording losses, but the eventual gap event or news spike that causes a $2,000+ adverse move is inevitable on XAUUSD. A stop loss that is too tight is nearly as bad โ market noise on M15 gold is typically 10โ20 pips, and tight stops destroy win rate. The right SL is ATR-based: wide enough to avoid noise, tight enough to define risk. The optimizer widget below gives you specific values for your setup.
Why No-Stop-Loss Strategies Eventually Blow Accounts
The appeal of no-SL strategies is simple: they show high win rates and smooth equity curves in backtests. Every losing position simply stays open until it recovers โ or until the account runs out of margin. In a backtest, the historical data is finite and the worst moves have already happened. The strategy can be designed around them or they may simply not be present in the test window.
In live trading, the distribution of adverse moves on XAUUSD is fat-tailed โ extreme events occur more frequently than a normal distribution would predict. Gold gaps at Sunday market open (from Friday's close to Sunday's open) regularly reach 30โ80 pips. Fed meeting announcements, CPI prints, and geopolitical shocks can produce moves of 200โ500 pips in minutes. Without a stop loss, these events do not cause a controlled drawdown โ they cause account-ending losses.
The Black Swan Mathematics
Sunday gap (weekly)
Move: 20โ80 pips
Frequency: ~50 per year
Without SL: position held over gap, opened in deficit
Major news spike (Fed, CPI)
Move: 100โ300 pips in 60 seconds
Frequency: ~20 per year
Without SL: position cannot be closed during spike; fills at extreme price
Geopolitical shock
Move: 200โ500 pips intraday
Frequency: 2โ5 per year
Without SL: account can be depleted in a single event regardless of prior profits
Why Stops That Are Too Tight Are Almost as Damaging
Gold on M15 is a noisy instrument. The ATR (average true range) of a single M15 candle typically measures 12โ20 pips during London session, rising to 20โ35 pips during London/New York overlap. A stop loss of 5โ10 pips will be hit by normal market noise on a routine basis, independent of whether the trade direction was correct.
The mathematical consequence: suppose your breakout EA has a correct directional bias 60% of the time, but a 5-pip stop is hit before the move develops 40% of the time (even on correct-direction trades). Your effective win rate collapses from 60% to 36% โ which is no longer profitable at any typical risk-reward ratio.
XAUUSD M15 ATR Reference (Average Values)
Asian
8โ12 pips
Low volatility. Tight SL borderline viable.
London open
15โ25 pips
High volatility. 5-pip SL will be hit by noise.
NY open
18โ30 pips
Highest volatility. SL must be wider than 20 pips.
NY/London overlap
20โ35 pips
Peak ATR. Minimum viable SL is 25โ30 pips.
Stop Loss Width Optimizer
Configure your setup to get a recommended SL range for your XAUUSD EA.
XAUUSD M15 ATR (current)
Strategy type
Account sensitivity
Recommended SL range
26โ31 pips
Target TP (1:1.5 R:R)
39โ44 pips
Max acceptable spread
7 pips
Martingale recovery needed?
Never
How to Calculate SL Width Using ATR
ATR (Average True Range) measures the average pip movement of a candle over a lookback period. It is the most objective measure of market noise on any given timeframe, and therefore the most rational basis for setting a stop loss.
The formula is straightforward: multiply the ATR by a factor between 1.0 and 2.0, depending on your strategy's sensitivity to noise. A breakout EA on M15 typically uses ATR ร 1.2โ1.5. A trend-following EA on H1 typically uses ATR ร 1.5โ2.0. The multiplier is the single most important number to calibrate during backtesting.
// MT5 MQL5 โ ATR-based stop loss calculation
double atr = iATR(Symbol(), PERIOD_M15, 14, 0);
double atrMultiplier = 1.3; // adjust per strategy type
double stopLossPips = atr * atrMultiplier / Point;
double stopLossPrice = OrderType() == OP_BUY
? Ask - stopLossPips * Point
: Bid + stopLossPips * Point;This calculates a dynamic stop loss that adapts to current market volatility. During high-ATR sessions (NY open), the stop automatically widens. During low-ATR sessions (Asian), it tightens. This is more robust than a fixed pip value because it reflects what the market is actually doing.
Goldie Razor V2.8.4 uses a different but equally principled approach: the stop loss is placed at the opposite boundary of the detected M15 range โ not at an ATR multiple from entry, but at the structural level that, if breached, confirms the breakout has failed. This is range-based rather than ATR-based, but it achieves the same goal: a stop that reflects market structure rather than an arbitrary pip count.
Why Martingale "Recovery" Is Not a Stop Loss Substitute
Martingale strategies double position size after each loss, so that a single winning trade recovers all previous losses and produces a profit equal to the original risk. The mathematics work perfectly on paper โ given infinite capital, infinite time, and no maximum loss event.
In practice, all three assumptions fail on XAUUSD. Capital is finite. The market occasionally produces 5โ8 consecutive losing setups. And news events create moves so large that doubling the position makes the loss worse, not better.
6-Step Martingale on 0.01 Starting Lot โ What Happens When All 6 Lose
| Step | Lot Size | Individual Loss ($) | Cumulative Loss ($) |
|---|---|---|---|
| 1 | 0.01 | โ$30 | โ$30 |
| 2 | 0.02 | โ$60 | โ$90 |
| 3 | 0.04 | โ$120 | โ$210 |
| 4 | 0.08 | โ$240 | โ$450 |
| 5 | 0.16 | โ$480 | โ$930 |
| 6 | 0.32 | โ$960 | โ$1890 |
Starting with 0.01 lots and a 30-pip SL equivalent loss, a 6-loss sequence produces $1,890 cumulative damage โ 18.9% of a $10,000 account, from a position that started at 0.01 lots. A 5-step version halves this, but the risk compounds rapidly regardless of starting size.
How to Test Stop Loss Width in MT5 Strategy Tester
MT5's Strategy Tester provides a reliable method for comparing SL widths systematically. The key is testing on tick data with real spreads applied, not on OHLC bars with default spread โ the difference can significantly affect measured performance.
Set up the test correctly
In Strategy Tester, select "Every tick based on real ticks" as the modelling method. Set the spread to "Current spread" or enter the actual typical spread for XAUUSD at your broker (usually 15โ25 pips). Use at least 3 years of data to capture different market regimes.
Run the optimiser on SL width
Add SL width as an optimisation parameter. Test from 10 pips to 50 pips in 5-pip steps. For each SL value, note: win rate, profit factor, maximum drawdown, and Sharpe ratio. Do not just optimise for net profit โ the combination of drawdown and profit factor is more meaningful.
Apply walk-forward testing
Divide the historical data: optimise on the first 60%, then test the optimised SL on the remaining 40% without re-optimising. If the SL that performs best in-sample also performs well out-of-sample, it is a robust choice. If out-of-sample performance degrades significantly, the in-sample result was overfitted.
Check performance around known extreme events
Identify dates of major gold market moves: March 2020 (COVID crash), February 2022 (Ukraine), October 2023 (Middle East tensions). Filter your backtest results for these periods specifically and check how the chosen SL width performed. A robust SL should survive these events with controlled drawdown.
Related Reading
Stop loss settings guide for XAUUSD
The specific values for SL settings that have performed well across different XAUUSD strategies and timeframes.
How SL discipline connects to long-term consistency
Why stop loss discipline is one of the most important levers in building sustainable XAUUSD trading results.
The maths of gold scalping
A full look at the economics of XAUUSD scalping โ spread costs, win rate requirements, and capital efficiency.
How slippage affects stop loss execution
Why a 20-pip stop loss sometimes executes at 22โ24 pips โ and how to factor this into your SL sizing.
The full profitability picture for automated gold trading
How stop loss discipline fits into the broader framework of building a profitable gold EA.
Frequently Asked Questions
The most defensible approach is ATR-based: measure the 14-period ATR on M15, then set your stop loss at 1.0โ1.5ร that value. On XAUUSD, M15 ATR typically ranges from 12โ25 pips depending on session and volatility regime. This places the stop loss just beyond normal market noise, allowing the trade room to breathe while limiting loss on a genuine reversal. A fixed stop loss (e.g., always 20 pips) is simpler but does not adapt to changing volatility โ acceptable if you monitor it and adjust during extreme conditions.
Because no-SL strategies often look excellent in backtests. Without a stop loss, the strategy never takes a "loss" โ it either closes at profit or holds the position until it recovers (or until it destroys the account). Backtests on historical data often do not include the extreme moves (flash crashes, news spikes, Fed announcements) that trigger account-ending events without a stop. The strategy looks smooth until the one event that wipes it out โ which may not have occurred in the backtest period.
Yes โ and this is important. A stop loss at 5 pips on XAUUSD M15 will be hit by normal market noise multiple times per session, even when the trade direction is ultimately correct. The result is a string of small losses that accumulate into a larger drawdown than a wider stop with fewer triggers would have produced. The net effect is a reduced win rate and worse overall expectancy. This is why stop loss size should be based on ATR or range boundaries, not arbitrary round numbers.
A hard (fixed) stop loss is set at a specific price level when the trade opens and does not move. It is the minimum viable protection against catastrophic loss. A trailing stop moves with price as the trade goes in your favour โ locking in profit as the move extends. Hard stops are simpler and ensure protection even if the EA disconnects. Trailing stops require the EA to remain connected to function (or must be placed as MT5 trailing stops on the broker server). The best practice is hard SL from the start, with trailing logic added on top once in profit.
Martingale doubles position size after each loss to recover from previous losses with a single winning trade. The mathematics only work if you have unlimited capital and there is no maximum loss event. On XAUUSD, a 6-step martingale sequence starting at 0.01 lots requires 0.64 lots on the final trade โ and if that trade also loses, the total loss is approximately 1.27 lots equivalent of damage, which is catastrophic on a standard account. Martingale does not solve the stop loss problem; it defers and amplifies it.
Goldie Razor V2.8.4
M15 breakout + H4 EMA filter โ built for XAUUSD on MT5