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

ConditionFixed 2% StopATR Stop (2x)
High Volatility (ATR = 3%)Too tight, whipsaws6% - room to breathe
Low Volatility (ATR = 0.5%)Too wide1% - tighter, less risk
Market ShiftNo adaptationAutomatically 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:

PeriodBehaviorUse Case
7-10Responsive, changes quicklyShort-term trading
14Balanced (default)Most strategies
20-50Smooth, slower to adaptLong-term positions

ATR Multiplier

How many ATRs away to place the stop:

MultiplierStop DistanceRisk Level
1.0xTightHigher chance of stop-out
1.5xModerateBalanced protection
2.0xStandard (recommended)Room for normal volatility
2.5-3.0xWideMaximum 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:

  1. Select the strategy
  2. ATR settings are shown in Position Settings
  3. 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

MethodProsCons
Fixed %Simple, predictableDoesn't adapt to volatility
Fixed PricePrecise levelsRequires manual calculation
Trailing %Locks in profitsCan exit too early in trends
ATRAdapts to marketRequires 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

  1. Check current ATR - Market may be very volatile
  2. Reduce multiplier - Use 1.5x instead of 2.0x
  3. Use shorter period - More responsive to calming markets

Stop Seems Too Tight

  1. Check current ATR - Market may be very calm
  2. Increase multiplier - Use 2.5x instead of 2.0x
  3. Use longer period - Less reactive to spikes

Stop Not Updating

  1. Verify ATR mode - Check strategy uses ATR stops
  2. Check for errors - Review bot logs
  3. 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

  1. Match period to timeframe

    • Higher timeframes: longer ATR periods
    • Lower timeframes: shorter ATR periods
  2. Backtest multiplier settings

    • Test different multipliers on historical data
    • Find balance between protection and room
  3. Consider position sizing

    • ATR can also inform position size
    • Risk fixed dollar amount based on ATR distance
  4. Monitor in volatile periods

    • ATR expands rapidly during news events
    • Stops will widen automatically
  5. Combine with other analysis

    • ATR stops work well with support/resistance
    • Consider adjusting multiplier near key levels

Related Documentation