Appends two columns, not three. There is no ${prefix}Middle: the
middle is the field itself, already on the series as column — a third
column would be a copy of one the caller passed in, which is a column to
keep in step rather than a measurement. (Contrast keltner and
bollinger, whose centres are computed — a moving average the
caller does not otherwise have — and are therefore worth appending.)
Definition
The half-width is Wilder's ATR, the same atrValues kernel call
atr makes, at the same default period 14. That is the whole
study: atrBands is atr() plus two additions, and
${prefix}Upper − column === multiplier × atr holds bit-for-bit, not
to rounding — pinned by a test against the shipped atr study rather than
asserted here. TA-Lib has no ATR-band function; the oracle is a pandas
replication on the ATR reference it already cross-checks against TA-Lib,
so the numbers are TA-Lib's ATR with arithmetic on top.
Four inputs, and why column is separate from close
column is what the bands are drawn around; high / low / close
are what the ATR is computed from. They default to the same 'close',
and separating them is what lets the bands sit on something the ATR is
not measured from — bands around an sma, say
({ column: 'sma' }) — which is the usual reason to reach for this study
rather than keltner. Redirect all four together to run the study
on a second instrument's columns.
Warm-up and edges
Both bands start at bar period, the ATR's own first bar (true
range needs a previous close, so a period-bar average of it lands one
bar later than a period-bar window would — the atr off-by-one). If
column warms up later than that (bands around another study's output),
the bands start where it does; NaN propagates through the addition
with no branch.
In the units of the price: scaling every bar scales both bands.
A leading gap shifts the Wilder seed; an interior gap propagates to
the end — inherent to Wilder smoothing, and the same asymmetry atr
documents. A gap in column alone costs only that bar.
No division, so no zero-denominator case: a flat stretch gives
ATR = 0 and both bands sit on the field.
ATR Bands — a field with a volatility band either side of it:
Appends two columns, not three. There is no
${prefix}Middle: the middle is the field itself, already on the series ascolumn— a third column would be a copy of one the caller passed in, which is a column to keep in step rather than a measurement. (Contrast keltner and bollinger, whose centres are computed — a moving average the caller does not otherwise have — and are therefore worth appending.)Definition
The half-width is Wilder's ATR, the same
atrValueskernel call atr makes, at the same defaultperiod 14. That is the whole study:atrBandsisatr()plus two additions, and${prefix}Upper − column === multiplier × atrholds bit-for-bit, not to rounding — pinned by a test against the shippedatrstudy rather than asserted here. TA-Lib has no ATR-band function; the oracle is a pandas replication on the ATR reference it already cross-checks against TA-Lib, so the numbers are TA-Lib's ATR with arithmetic on top.Four inputs, and why
columnis separate fromclosecolumnis what the bands are drawn around;high/low/closeare what the ATR is computed from. They default to the same'close', and separating them is what lets the bands sit on something the ATR is not measured from — bands around ansma, say ({ column: 'sma' }) — which is the usual reason to reach for this study rather than keltner. Redirect all four together to run the study on a second instrument's columns.Warm-up and edges
period, the ATR's own first bar (true range needs a previous close, so aperiod-bar average of it lands one bar later than aperiod-bar window would — theatroff-by-one). Ifcolumnwarms up later than that (bands around another study's output), the bands start where it does;NaNpropagates through the addition with no branch.atrdocuments. A gap incolumnalone costs only that bar.ATR = 0and both bands sit on the field.