ATR-Based Stop Loss
ATR (Average True Range) stop-loss adapts to market volatility, providing wider stops in volatile conditions and tighter stops in calm markets.
What is ATR?
Average True Range measures market volatility by calculating the average of "true ranges" over a period. The true range for each candle is the greatest of:
- Current High - Current Low
- |Current High - Previous Close|
- |Current Low - Previous Close|
Example True Range Calculation:
Candle: High $51,000, Low $49,000, Prev Close $50,500
TR1 = $51,000 - $49,000 = $2,000
TR2 = |$51,000 - $50,500| = $500
TR3 = |$49,000 - $50,500| = $1,500
True Range = max($2,000, $500, $1,500) = $2,000
ATR is the average of true ranges over N periods (typically 14).
Why Use ATR for Stops?
Fixed Percentage Problems
With fixed percentage stops:
- Volatile markets: 2% stop might trigger on normal noise
- Calm markets: 2% stop might be too wide, risking more than necessary
ATR Advantages
| Condition | Fixed 2% Stop | ATR Stop (2x) |
|---|---|---|
| High Volatility (ATR = 3%) | Too tight, whipsaws | 6% - room to breathe |
| Low Volatility (ATR = 0.5%) | Too wide | 1% - tighter, less risk |
| Market Shift | No adaptation | Automatically adjusts |
How ATR Stop-Loss Works
Calculation
For Long Positions:
Stop Loss = Entry Price - (ATR × Multiplier)
For Short Positions:
Stop Loss = Entry Price + (ATR × Multiplier)
Example
Entry Price: $50,000 (Long)
ATR (14-period): $1,200
Multiplier: 2.0
Stop Loss = $50,000 - ($1,200 × 2.0)
Stop Loss = $50,000 - $2,400
Stop Loss = $47,600
Risk per unit: $2,400 (4.8%)
ATR Parameters
ATR Period
Number of candles used to calculate the average:
| Period | Behavior | Use Case |
|---|---|---|
| 7-10 | Responsive, changes quickly | Short-term trading |
| 14 | Balanced (default) | Most strategies |
| 20-50 | Smooth, slower to adapt | Long-term positions |
ATR Multiplier
How many ATRs away to place the stop:
| Multiplier | Stop Distance | Risk Level |
|---|---|---|
| 1.0x | Tight | Higher chance of stop-out |
| 1.5x | Moderate | Balanced protection |
| 2.0x | Standard (recommended) | Room for normal volatility |
| 2.5-3.0x | Wide | Maximum room, higher risk |
Configuring ATR Stops
For Trading Bots
ATR stop-loss is configured at the strategy level. Strategy authors define:
dcaConfig: {
enabled: true,
stopLossMode: 'atr',
atrPeriod: 14, // 14 candles
atrMultiplier: 2.0 // 2x ATR distance
}
When creating a bot with this strategy:
- Select the strategy
- ATR settings are shown in Position Settings
- Values are read-only (set by strategy)
For Custom Strategies
In your strategy code:
// Access ATR indicator
const atr = td.indicators.atr(14);
const currentATR = atr[atr.length - 1];
// Calculate stop-loss
const stopDistance = currentATR * 2.0;
const stopPrice = td.position.isLong
? td.position.avgEntryPrice - stopDistance
: td.position.avgEntryPrice + stopDistance;
// Update stop-loss
td.trade.updateStopLoss(stopPrice);
ATR with DCA Positions
When using DCA (Dollar Cost Averaging), ATR stops are recalculated after each entry based on the new average entry price:
Level 1: Entry $50,000
ATR: $1,200, Multiplier: 2x
Stop: $50,000 - $2,400 = $47,600
Level 2: Entry $48,000, Avg Entry: $49,000
ATR: $1,300 (volatility increased)
Stop: $49,000 - $2,600 = $46,400
Level 3: Entry $46,000, Avg Entry: $48,000
ATR: $1,400 (more volatility)
Stop: $48,000 - $2,800 = $45,200
Notice how:
- Stop moves with average entry
- ATR adapts to current volatility
- Distance adjusts automatically
Comparing Stop-Loss Methods
| Method | Pros | Cons |
|---|---|---|
| Fixed % | Simple, predictable | Doesn't adapt to volatility |
| Fixed Price | Precise levels | Requires manual calculation |
| Trailing % | Locks in profits | Can exit too early in trends |
| ATR | Adapts to market | Requires understanding ATR |
When to Use ATR
Best for:
- Trending strategies
- Multiple timeframe analysis
- Volatile markets (crypto, forex)
- DCA strategies
Not ideal for:
- Ultra-short timeframes (noise in ATR)
- Range-bound strategies
- Specific price level targets
Practical Examples
Conservative Setup
ATR Period: 20 (smoother)
ATR Multiplier: 2.5 (wider)
Result: Wide stops, fewer whipsaws, higher risk per trade
Aggressive Setup
ATR Period: 10 (responsive)
ATR Multiplier: 1.5 (tighter)
Result: Tight stops, more frequent exits, lower risk per trade
Balanced Setup (Recommended)
ATR Period: 14 (standard)
ATR Multiplier: 2.0 (balanced)
Result: Adapts reasonably, protects against normal volatility
Monitoring ATR Stops
Dashboard Display
When ATR stop-loss is active:
Stop-Loss
├── Mode: ATR
├── ATR Period: 14
├── ATR Multiplier: 2.0x
├── Current ATR: $1,250
├── Stop Distance: $2,500
└── Stop Price: $47,500
Understanding Changes
ATR value changes each candle. Your stop will move:
- ATR increases: Stop moves further from entry (wider)
- ATR decreases: Stop moves closer to entry (tighter)
- New DCA entry: Stop recalculated from new average
Troubleshooting
Stop Seems Too Wide
- Check current ATR - Market may be very volatile
- Reduce multiplier - Use 1.5x instead of 2.0x
- Use shorter period - More responsive to calming markets
Stop Seems Too Tight
- Check current ATR - Market may be very calm
- Increase multiplier - Use 2.5x instead of 2.0x
- Use longer period - Less reactive to spikes
Stop Not Updating
- Verify ATR mode - Check strategy uses ATR stops
- Check for errors - Review bot logs
- Manual check - Calculate expected stop manually
ATR Calculation Differences
Different platforms may calculate ATR slightly differently:
- Some use SMA of true ranges
- Some use EMA (Wilder's smoothing)
- Verify which method your strategy uses
Best Practices
-
Match period to timeframe
- Higher timeframes: longer ATR periods
- Lower timeframes: shorter ATR periods
-
Backtest multiplier settings
- Test different multipliers on historical data
- Find balance between protection and room
-
Consider position sizing
- ATR can also inform position size
- Risk fixed dollar amount based on ATR distance
-
Monitor in volatile periods
- ATR expands rapidly during news events
- Stops will widen automatically
-
Combine with other analysis
- ATR stops work well with support/resistance
- Consider adjusting multiplier near key levels
Related Documentation
- DCA for Trading Bots - DCA with ATR stops
- Risk Management - Overall risk strategy
- Indicators - Technical indicators reference
- DCA Troubleshooting - DCA problem solving