Summary
RandomWalkIndex is RTTA's streaming Random Walk Index (RWI). For every lag
from 1 through window, it compares directional price travel with average true
range times the square root of that lag, then returns the largest high-side and
low-side readings.
Update API
result = rtta.RandomWalkIndex(window=14, fillna=True).update(close, high, low)
# result.high, result.low
Theory Of Operation
Under a simple diffusion model, expected travel grows approximately with
\(\sigma\sqrt{k}\). RWI uses average true range as the volatility scale and asks
whether an observed move over any horizon \(k\le n\) is unusually large. Taking
the maximum over every horizon is fundamental to RWI: using one window-wide
extreme and a single ATR is a different statistic.
Recurrence
Let \(n\) denote window, and define true range in the usual way:
For each \(k=1,\ldots,n\), use the \(k\) true ranges ending one bar before the current observation:
Then
Division uses RTTA's safe divide. Result field high is RWIHigh; field low
is RWILow.
The complete calculation needs window prior bars plus the current bar. With
fillna=False, the first window updates return NaN; update window + 1
returns the first complete result. With fillna=True, startup maximizes over
the lags currently available, and the first observation returns zero for both
sides.
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in
class RandomWalkIndex. Rolling high, low, and true-range buffers allow each
candidate horizon to be evaluated without recomputing input history.
