Summary
CDLDojiStar is RTTA's streaming detector for the Doji star candlestick pattern.
A doji after a long body, often as a star after a directional push (reversal risk).
Output follows the TA-Lib convention: +100 for a bullish match, -100
for a bearish match, and 0 when the pattern does not fire.
Update API
value = rtta.CDLDojiStar(fillna=True).update(open, high, low, close)
# +100 bullish match, -100 bearish match (when directional), 0 no match
batch = rtta.CDLDojiStar(fillna=True).batch(open, high, low, close)
update(...) consumes one OHLC bar. advance(...) uses the same inputs without
returning a Python value. Scalar batch(open, high, low, close) matches sequential
update on a fresh instance. With fillna=False, values are NaN until at least
2 bar(s) have been seen; with fillna=True (default), unmatched bars return 0.
Theory Of Operation
Candlestick patterns are short causal labels on bar geometry. They do not forecast returns by themselves; they tag structure (indecision, rejection, engulfing pressure, multi-bar reversals) that you can combine with trend, volatility, or volume context.
On every bar the engine forms:
A bar is bullish when \(C_t \ge O_t\) and bearish when \(C_t < O_t\). Bars are stored in a short ring; age \(0\) is the newest bar, age \(1\) the prior bar, and so on.
Shared predicates used below:
\(\overline B\) is the average body over the last up to five ring bars; \(\overline R\) is the average range over the same window.
For hammer-family patterns, a light prior trend uses the previous close versus the SMA of the two closes before it:
Recurrence
Push \((O_t,H_t,L_t,C_t)\) into the ring. Detection runs only when the ring has at least 2 bar(s).
Require \(\mathrm{doji}(c)\) and \(\mathrm{longBody}(p,\overline B,0.8)\).
- After a bull prior: prefer gap-up star \(\mathrm{bot}_c > \mathrm{top}_p\) → \(-100\) (also \(-100\) if no gap).
- After a bear prior: prefer gap-down star \(\mathrm{top}_c < \mathrm{bot}_p\) → \(+100\) (also \(+100\) if no gap).
If the predicate fails, emit \(0\). The C++ path is \(O(1)\) per update (fixed ring, no full-window rescan beyond a few bars).
Implementation Notes
The recurrence is implemented in src/rtta/indicator.cpp in class CDLDojiStar,
built on shared CdlHistory / cdl:: geometry helpers. Thresholds are
streaming-friendly geometric rules; they are not a line-by-line port of every
TA-Lib average-body lookback table.
