Stop Loss Rule in a Backtest
How Do You Backtest Stop Losses Realistically?
A stop loss is a safety rule: if the trade moves against you, you exit automatically at a specified loss. In backtesting, stop losses are the difference between a system that blows up and one that survives. Yet most traders mishandle stops in backtests. They optimize stops based on past results, or they apply stops inconsistently (tight in some trades, loose in others), or they forget that a real stop might not fill at the exact price you specified. This article teaches you how to backtest stop losses honestly, and how to choose a stop loss level that protects capital without destroying the win rate.
Quick definition: A stop loss is a predetermined price or loss level at which you automatically exit a losing trade, limiting the damage to a fixed amount of capital or percentage.
Key takeaways
- Stop losses must be set before the backtest, not optimized after seeing results.
- Real stops often fill at worse prices than expected due to slippage and gaps.
- The deeper your stop loss, the more room your trade has to work; the tighter it is, the more you're whipped out by noise.
- Stop losses based on volatility (ATR) often work better than fixed percentages.
- A stop loss that's too tight can be worse than no stop loss because it crystallizes small losses before they recover.
Why Stops Matter in a Backtest
In live trading, a stop loss is a circuit breaker. You buy at $100, set a stop at $99, and if the price hits $99, you're out. The worst you lose is $1 per share. Without that stop, the price could drop to $80 and you're out $20. A stop loss protects you from catastrophic loss.
In a backtest, a stop loss does the same thing—but the results depend entirely on how you model the stop. If you assume the stop fills at exactly the right price, the backtest will look better than real trading. If you assume the stop never fills, the results will be unrealistic. And if you adjust the stop after the fact to "improve" the backtest, you've broken the test.
Fixed Percentage Stop Losses
The simplest stop loss is a fixed percentage below entry.
1% stop loss: "Buy at $100. If the price falls to $99 or below, exit the entire position."
2% stop loss: "Buy at $100. If the price falls to $98 or below, exit."
5% stop loss: "Buy at $100. If the price falls to $95 or below, exit."
Fixed percentage stops are easy to understand and easy to test. The question is: which percentage? A 1% stop is tight; it will be hit often by intraday noise. A 5% stop is loose; it gives the trade room to work but allows larger losses.
The historical choice depends on your market. In stocks, 2-3% is common. In commodities, which are more volatile, 5-10% is common. In forex, 1-2% is common. These are just anchors, not rules. Your stop should fit your strategy.
Fixed-Dollar Stop Losses
Instead of a percentage, you can specify a fixed dollar loss per position.
$500 stop loss: "Buy 100 shares at $100. If the price falls so that the total position loss exceeds $500, exit."
$1,000 stop loss: "Buy 50 shares at $100. If the loss exceeds $1,000, exit."
Fixed-dollar stops are useful when you're thinking in terms of account risk. If your account is $50,000 and you risk $500 per trade, you can take 100 losses before you blow up (assuming losses of exactly $500 and no wins). That clarity is valuable.
Volatility-Based Stop Losses Using ATR
A volatility-based stop loss adapts to market conditions. When the market is quiet, the stop is tight. When it's volatile, the stop is loose.
ATR stop loss: "The average true range (ATR) over the last 14 bars is $1.50. Set a stop loss at entry price minus 2 ATR. Stop = Entry - (2 × $1.50) = Entry - $3.00."
If ATR rises to $2, the stop becomes Entry - $4. This automatically adapts to the current volatility.
Volatility-based stops are elegant because they respect market conditions. In a quiet stock, you don't want a 5% stop because the stock might drop 4% and recover naturally. In a volatile stock, a 2% stop is ridiculous because the stock moves 2% in a day. ATR handles this.
Technical stops based on price structure
Structure-based stop: "The previous swing low is $97. Set the stop at $97. If the price falls below it, exit."
This places the stop at a logical support level, not at a fixed percentage. If support is at $97 and the price drops below it, the structure is broken and the trade is invalid.
Stop Loss Placement in the Backtest
When you backtest a stop loss, you need to decide when it triggers. This matters.
Option 1: Intraday stop. "If the price touches the stop level during the bar (high > stop or low < stop for a long), exit immediately at the stop price."
This is most optimistic because you're assuming the stop is hit at exactly the right price. In reality, if the price gaps through the stop, you fill worse.
Option 2: Close-based stop. "If the close is below the stop level, exit at the next bar's open."
This is more conservative and more realistic. You don't exit until the bar closes below the stop, and you fill at the next bar's open, not at the exact stop price.
Option 3: Gap stop. "If the price opens below the stop level, exit at the opening price."
This handles overnight gaps. The stock can close above the stop and open below it. You get filled at the open, which might be much worse than the stop price.
For honest backtesting, use Option 3 or Option 2. Option 1 (intraday stop at exact price) makes the system look better than it will actually trade.
The Psychology of Stop Losses in Backtests
Backtesting reveals a brutal truth: stops are uncomfortable. After you backtest, you'll see trades that hit your stop loss, then reversed and became winners. Those are called "whipsaws." Your 2% stop stopped you out at exactly $98, and the stock rebounded to $105. The stop did its job (protected you if the loss continued), but it also took you out of a winner.
This discomfort is why traders are tempted to widen stops after the fact. "If I had used a 3% stop instead of 2%, I would have captured that trade." True, but you don't know that before the fact. Widening the stop after seeing the results is optimization bias.
The answer is to accept whipsaws. They're a cost of trading. Some trades are taken out by stops that would have recovered. That's the nature of risk management. The traders who move their stops to reduce whipsaws end up with larger losses on the trades that don't recover.
Stop Loss and Win Rate
There's a relationship between stop loss and win rate. A tight stop loses often. A loose stop loses less often.
Tight stop (1%): Win rate might be 35%. Average win is $3. Average loss is $1. Profit factor (total wins / total losses) is 1.05. System barely works.
Medium stop (3%): Win rate might be 45%. Average win is $4. Average loss is $3. Profit factor is 1.2. System is better.
Loose stop (5%): Win rate might be 55%. Average win is $4. Average loss is $5. Profit factor is 0.88. System is worse.
The point is: a tighter stop doesn't automatically make a better system. Win rate is a tradeoff. A 1% stop might win more often but lose more on the rare big loss. A 5% stop might lose more often but when it loses, the loss is smaller (as a percentage of the account).
The best stop loss is the one that fits your edge. If your edge is catching quick reversals (mean reversion), a tight 2% stop works because you expect to get in and out fast. If your edge is riding trends, a loose 5% or trailing stop works because you need room for the position to breathe.
Decision tree
Testing Your Stop Loss Assumption
Before you backtest, think through how stops will behave in real trading.
Test 1: Will the stop fill at the exact price? No. In real trading, if you set a stop at $99 on a $100 entry and the stock gaps down to $97 overnight, you fill at $97, not $99. Your backtest should assume the stop fills at the next bar's open or worse.
Test 2: What if the stock gaps past the stop? This happens. A stock can close above your stop at 4:00 PM and open below it at 9:30 AM the next day. Account for this in your backtest by assuming you fill at the opening price after a gap.
Test 3: Can you hit the stop multiple times? In some backtests, a stock might touch the stop intraday, then recover, then touch it again. Your rule should specify: once you hit the stop, you're out. No second chances.
Real-World Stop Loss Examples
Example 1: Mean Reversion Stop
"Buy when RSI < 30. Set stop at entry - 2%. Hold for max 5 days. Exit when RSI > 60 or stop is hit, whichever first."
This stop is tight (2%) because the trade should reverse quickly. If it doesn't recover within 5 days, you're out anyway.
Example 2: Breakout Stop
"Buy above the 20-day high. Set stop at the 10-day low. Exit if price falls below the 10-day low."
This stop is structure-based. The breakout is invalid if the price falls below the recent low.
Example 3: Trend-Following Stop
"Buy above the 50-day MA. Set stop at entry - 2 ATR. Trailing stop: as price rises, move stop up to maintain 2 ATR distance."
This stop adapts to volatility and lets winners run while protecting gains.
Common Stop Loss Mistakes
Mistake 1: Changing the stop after the backtest. You run a backtest with a 2% stop, see the results, and think "if I had used 2.5%, I would have done better." That's optimization bias. Set the stop before the backtest.
Mistake 2: Using different stops for different trades. A 1% stop on some trades and 5% on others is inconsistent. If you have a reason to use different stops (different volatility, different strategy), write that reason down and backtest each separately.
Mistake 3: Not accounting for gaps. Your backtest fills the stop at exactly the stop price, but real trading has overnight gaps. A stock can fall past your stop without hitting it intraday.
Mistake 4: Stops that are too tight. A 0.5% stop in a moderately volatile stock means you're hit constantly by intraday noise. You might be right about the direction but stopped out before the move starts.
Mistake 5: Stops that are too loose. A 10% stop is so loose that you might as well not have one. The loss is large, the drawdown is severe, and one bad trade can wipe out 10 small wins.
FAQ
Should I use a percentage stop or a dollar stop?
Percentage is clearer because it's proportional to the position size. A 2% stop on a $100 stock ($2 loss) and a 2% stop on a $20 stock ($0.40 loss) are different in absolute terms but equivalent in risk. Stick with percentages.
What if my stop is set too tight and I'm stopped out every few trades?
That's data. If the backtest shows a 2% stop loses money (too many whipsaws), try 3% or 4%. The backtest will show the best stop level for your entry.
Can I move my stop loss up to breakeven after the trade profits?
Yes, that's a valid rule. "After the trade is up 1%, move the stop to breakeven (entry price)." This locks in a win and removes downside risk. Write it down and backtest it.
Should I use a hard stop or a mental stop?
In a backtest, they're the same—both are rules. In real trading, use a hard stop (actually place the order). Mental stops are almost never executed when needed.
How do I choose between a fixed stop and an ATR stop?
Backtest both. Run one backtest with 2% stops and another with 2-ATR stops. The results will show which works better for your market and entry.
What if the stock gaps through my stop without triggering it intraday?
Your backtest should handle this. If you set a stop at $99 and the stock closes at $99.50 (above the stop), then opens at $98 the next day (below the stop), you exit at the open. You don't get your $99 stop; you get $98.
Related concepts
- Exit Rule: A Clear Definition — How exit rules include stop losses.
- Position Sizing in a Backtest — How position size interacts with stops.
- Risk of Ruin Overview — How stops affect the probability of losing your account.
- Defining Rules Before Backtesting — Stops are part of your overall rule system.
Summary
A stop loss is a safety rule that exits a losing trade before losses get too large. It can be based on a fixed percentage, a fixed dollar amount, or volatility (ATR). Set the stop before the backtest and don't change it afterward. In your backtest model, assume the stop fills at the next bar's open or worse, not at the exact stop price. Accept that some stops will be "whipsawed"—the trade reverses after you're stopped out. That's a cost of risk management, not a sign of a bad stop. The best stop loss depends on your market's volatility, your entry type, and your edge. A tight stop works for quick reversals. A loose or trailing stop works for trends. Test both and choose the one that produces the best risk-adjusted returns for your strategy.