Average true range
All indicators

LibraryVolatility

Indicator

Average true range

How far price typically moves in one bar, gaps from the previous close included, averaged over the length. It is in price units, so it grows and shrinks with the market's own swings.

VolatilityOwn pane1 inputATR

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

InputTypeDefaultRange or choices
LengthlengthWhole number14min 1, max 5000

What it draws

LineDrawn as
ATRLine

Used in

OrionQuant