Summary
KagiChart is a streaming Kagi line: the line tracks price in the current direction and
reverses only after an absolute move of size reversal against the line. Outputs are
the current line level, yang/yin direction, and a reversal flag.
Update API
import rtta
ind = rtta.KagiChart(reversal=1.0)
result = ind.update(price)
# result.line, result.direction (+1 yang / -1 yin / 0 unset),
# result.reversal (1 if direction flipped this tick else 0)
reversal is an absolute price amount (not percent), floored at \(10^{-12}\).
Theory Of Operation
Kagi charts ignore time and small noise: the line extends as long as price continues in the active direction; only a counter-move of at least the reversal amount flips yang (up, \(+1\)) to yin (down, \(-1\)) or vice versa. Classic charting also uses thick/thin lines at prior highs/lows; this implementation exposes the line, signed direction, and reversal events for quantitative use.
Recurrence
Let \(\delta =\)reversal. First price: \(\ell = p_0\), direction \(d=0\),
\(\mathrm{reversal}=0\).
If \(d \ge 0\) (flat or yang):
If \(d < 0\) (yin):
Outputs: \(\mathrm{line}_t=\ell\), \(\mathrm{direction}_t=d\).
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in class KagiChart.
Result type is KagiChartResult.
