Summary
ATR computes Average True Range, a volatility measure for OHLC streams. RTTA's
implementation is causal: each call to update(close, high, low) consumes one
bar, updates stored state, and returns the current average true range.
Update API
value = rtta.ATR(window=14.0, fillna=True).update(close, high, low)
Inputs are the current close, high, and low. The implementation stores the previous close, a running true-range sum for warmup, and the latest ATR value.
Theory Of Operation
True Range expands a bar's high-low range to include overnight or inter-bar
gaps from the previous close. ATR then smooths that true range. In RTTA, the
warmup phase returns the running average of all true ranges seen so far; after
window samples it switches to Wilder smoothing.
Recurrence
Let \(C_t\), \(H_t\), and \(L_t\) be close, high, and low for update \(t\), and
let \(n\) be window.
During warmup, with \(m_t = t + 1 \le n\):
After warmup:
If fillna=False, the object still updates all state during warmup, but returns
NaN until at least window samples have been consumed.
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in class ATR.
