Data Analytic Investments
Volatility & BandsBeginner

ATR

Average True Range

Measures market volatility in absolute price terms — the essential tool for position sizing and stop placement.

All timeframes
Crypto, Forex, Equities, Commodities
Pine Script v5

What is it?

Developed by J. Welles Wilder Jr. in 1978, ATR measures the average of the 'true range' over a lookback period (default 14). True range is the greatest of: (1) current high minus current low, (2) absolute value of current high minus previous close, (3) absolute value of current low minus previous close. This accounts for overnight gaps and limit moves. ATR does not indicate direction — only volatility magnitude. A rising ATR means volatility is expanding; a falling ATR means it is contracting.

When to use it

  • Stop-loss placement: set stops at 1.5–2× ATR below entry for longs (above for shorts) to avoid being stopped out by normal market noise.
  • Position sizing: divide your maximum dollar risk per trade by the ATR-based stop distance to calculate the correct position size.
  • Profit targets: use multiples of ATR (e.g. 2× or 3× ATR) as realistic take-profit levels based on the asset's typical daily range.
  • Volatility regime detection: compare current ATR to its 20-period average — if ATR is significantly above average, the market is in a high-volatility regime and position sizes should be reduced.
  • Trailing stops: a chandelier exit (highest high over N periods minus 3× ATR) is a classic ATR-based trailing stop that adapts to volatility.

Common pitfalls

  • ATR is not directional. A high ATR tells you the market is moving a lot — not which way. Never use it alone as a buy or sell signal.
  • ATR spikes during news events (CPI, Fed decisions, exchange hacks). A single high-volatility candle can inflate ATR for the entire lookback period.
  • Using a fixed ATR multiplier across all assets is dangerous. BTC's ATR as a percentage of price is very different from a stablecoin's. Always normalise by price (ATR%).
  • ATR on a 1-minute chart is dominated by bid-ask spread noise. It is most meaningful on 1H timeframes and above.
  • Wilder's original ATR uses a smoothed moving average (RMA), not a simple average. Many platforms default to SMA — check which calculation your platform uses.

Free code template

Paste directly into TradingView Pine Editor → Add to chart.

Pine Script v5
/indicator("ATR — DAI Template", shorttitle="DAI ATR", overlay=false)

atrLen = input.int(14, "ATR Length", minval=1)
atrVal = ta.atr(atrLen)
atrPct = atrVal / close * 100
atrAvg = ta.sma(atrVal, 20)
highVol = atrVal > atrAvg * 1.5

plot(atrPct, "ATR%", color = highVol ? #ef4444 : #f59e0b, linewidth=2)
plot(atrAvg / close * 100, "ATR% 20 SMA", color=color.new(#94a3b8, 40), linewidth=1)
bgcolor(highVol ? color.new(#ef4444, 92) : na)
alertcondition(highVol, "High Volatility", "ATR is 1.5x above its 20-period average")