Average True Range — Wilder's volatility measure: the
wilderValues | Wilder-smoothed average of the true range, where
true range is the widest of the three spans a bar can cover:
The last two terms are what make it true range rather than plain range:
a bar that gaps away from the previous close covers ground the bar's own
high-to-low span does not show.
Appends one column; undefined for the first period rows. True range
needs a previous close, so it is undefined on bar 0 and a period-bar
average of it first lands on bar period — the same off-by-one rsi
has, for the same reason.
The derivation itself is atrValues (true range, then Wilder), shared with
the other Wilder-family studies rather than owned here — keltner's band
half-width and atrBands call the same kernel, so they are this ATR and
not a second one.
Three inputs, not one
Every study before this took a single column. ATR reads high, low and
close, so instead of one source option it names each input, each
defaulting to its conventional bar-column name from DEFAULT_OHLCV. That
is the same rule the single-input studies follow — never hard-code a
column, always let the caller redirect it — applied three times rather
than a new mechanism.
Because all three are columns of one series, they are aligned by
construction: there is no way to hand ATR a high of a different length
from its close, which is a class of error array-based libraries have to
check for at every call.
Definition
TA-Lib's ATR, which is Wilder's: the true ranges are seeded on their
arithmetic mean over the first period values and then carried by
avg[i] = (avg[i−1]·(period−1) + TR[i]) / period. Verified against TA-Lib
bar-for-bar in the oracle fixture — exact agreement, and identical warm-up.
Edges
ATR is an absolute quantity, in the units of the price. It does not
normalise, so it is not comparable across instruments at different price
levels; divide by close for that (the "ATR percent" a caller can build
with percentChange-style arithmetic, deliberately not baked in).
A leading gap shifts the start, so running over columns that begin
with missing rows delays the study rather than emptying it.
An interior gap propagates to the end, inherent to Wilder smoothing —
a recursion has no state to carry across a hole. Note this differs from
ema(), whose interior gaps are skipped and recovered from; the two
smoothers genuinely differ here, and Wilder's answer is the conservative
one: a bar with no close leaves the true range of the NEXT bar unknown
too, so there is no honest value to resume from.
Average True Range — Wilder's volatility measure: the wilderValues | Wilder-smoothed average of the true range, where true range is the widest of the three spans a bar can cover:
The last two terms are what make it true range rather than plain range: a bar that gaps away from the previous close covers ground the bar's own high-to-low span does not show.
Appends one column;
undefinedfor the firstperiodrows. True range needs a previous close, so it is undefined on bar 0 and aperiod-bar average of it first lands on barperiod— the same off-by-one rsi has, for the same reason.The derivation itself is
atrValues(true range, then Wilder), shared with the other Wilder-family studies rather than owned here —keltner's band half-width andatrBandscall the same kernel, so they are this ATR and not a second one.Three inputs, not one
Every study before this took a single
column. ATR reads high, low and close, so instead of one source option it names each input, each defaulting to its conventional bar-column name fromDEFAULT_OHLCV. That is the same rule the single-input studies follow — never hard-code a column, always let the caller redirect it — applied three times rather than a new mechanism.Because all three are columns of one series, they are aligned by construction: there is no way to hand ATR a
highof a different length from itsclose, which is a class of error array-based libraries have to check for at every call.Definition
TA-Lib's ATR, which is Wilder's: the true ranges are seeded on their arithmetic mean over the first
periodvalues and then carried byavg[i] = (avg[i−1]·(period−1) + TR[i]) / period. Verified against TA-Lib bar-for-bar in the oracle fixture — exact agreement, and identical warm-up.Edges
ema(), whose interior gaps are skipped and recovered from; the two smoothers genuinely differ here, and Wilder's answer is the conservative one: a bar with no close leaves the true range of the NEXT bar unknown too, so there is no honest value to resume from.