How it is calculated
Each bar's true range is the largest of high minus low and the distances from the previous close to the high and to the low. The first bar has no previous close and is skipped. The first ATR is the plain mean of the first true ranges over the length, then Wilder's smoothing: the previous ATR times length minus one, plus the new true range, divided by the length. As TA-Lib ATR, after Wilder 1978.
Reference: TA-Lib ATR (Wilder 1978)
How to read it
A rising ATR means wider bars and a more nervous market, a falling one a quieter market. It says nothing about direction. Because it is in price units it cannot be compared across markets or over long stretches of history; NATR is made for that.
In a strategy
Stops and position sizes that follow volatility: a stop two ATRs below the entry, that is ctx.ind("atr", length=14) times 2, or a size that risks the same amount whatever the market's range.
Inputs
| Input | Type | Default | Range or choices |
|---|---|---|---|
Lengthlength | Whole number | 14 | min 1, max 5000 |
What it draws
| Line | Drawn as |
|---|---|
| ATR | Line |
Used in
The strategy templates whose code reads this indicator.