ATR is the average of the true range over the last N bars, where true range = max(high-low, |high-prev_close|, |low-prev_close|). The prev-close terms catch gap moves that a plain high-low would miss.
Formula
TR[t] = max(
high[t] - low[t],
|high[t] - close[t-1]|,
|low[t] - close[t-1]|
)
ATR[t] = EMA(TR, period)Params
period- averaging window. Default 14.
Output
Single column named after your indicator (e.g. atr).
Usage
ATR is the price-volatility unit that most stop and sizing calculations are built on:
- ATR-based stop loss:
stop_distance = ATR * multiplier. See ATR stop loss. - Volatility-adjusted position sizing:
size = capital * risk% / (ATR * mult). Position scales down automatically when ATR rises. - Filter regimes: skip trades when ATR is below or above a threshold (calm vs panic).
Pitfalls
- ATR is in price units, not percent. An ATR of 1500 on BTC at 60k is ~2.5%. The same ATR at 20k would be 7.5%. Always express multipliers in ATR units, never compare ATR values across price levels.
- Default period 14 is a starting point. Shorter ATR adapts faster but is noisier; longer ATR is smoother but lags real volatility shifts.
