Summary
SwingIndex is RTTA's streaming Welles Wilder Swing Index for a single bar
relative to the prior bar. It returns the bar's SI increment (not the cumulative
sum); use AccumulativeSwingIndex for the running
total.
Update API
value = rtta.SwingIndex(limit=0.5).update(open, high, low, close)
limit is the maximum expected price change scale (default \(0.5\)). The first
bar seeds previous OHLC and returns 0.0.
Theory Of Operation
Wilder's Swing Index combines the current open/close structure with gaps versus
the previous close to score how much of the bar is a genuine swing. The result
is scaled by limit so that SI is roughly comparable across instruments when
limit is set to a typical large move. Positive SI indicates bullish swing
structure; negative SI indicates bearish structure.
Recurrence
Let \(O_t, H_t, L_t, C_t\) be open, high, low, close and \(\ell =\) limit
(\(\ell > 0\), else defaulted to \(0.5\)).
Then previous OHLC is replaced by the current bar.
In particular, Wilder's \(C'_t\) term is the current bar's range. The previous low is retained as state for the next observation, but it is not used in that term.
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in class SwingIndex.
