Summary
EhlersCyberCycle is RTTA's streaming implementation of John Ehlers' cyber-cycle
oscillator. Price is lightly smoothed, then a two-pole high-pass extracts the
dominant cycle component. A one-bar lag of the cycle is returned as a trigger
line for cross-based timing.
Update API
result = rtta.EhlersCyberCycle(period=20, fillna=True).update(price)
| Parameter | Default | Meaning |
|---|---|---|
period |
20 |
High-pass critical period (minimum 2) |
fillna |
True |
If False, NaN until period samples |
update(...) returns:
cycle— current cyber-cycle valuetrigger— previous bar's cycle (one-bar lag used as trigger)
advance(price) updates state; last() returns the cached result.
Theory Of Operation
The cyber cycle is designed to isolate cyclic content while cancelling trend. RTTA follows Ehlers' practical streaming form:
- 4-bar weighted smooth of price (once enough history exists): \((x_t + 2x_{t-1} + 2x_{t-2} + x_{t-3})/6\).
- Two-pole high-pass of that smooth with coefficient \(\alpha\) from the critical period (same angle construction as the roofing high-pass, \(0.707\cdot 2\pi/P\)).
- During a short bootstrap (first 7 samples), a simple second-difference proxy is used so the filter is defined before full recursive state exists.
- The trigger is the previous cycle value, so crossings of cycle vs trigger mark short-term cycle turns.
Positive cycle values indicate the cyclic component is above its local zero; negative values indicate the opposite.
Recurrence
Alpha
Let \(P = \max(\texttt{period}, 2)\):
Price smooth
For sample index \(t \ge 3\) (zero-based count \(\ge 3\)):
Otherwise \(s_t = x_t\).
Cycle bootstrap (\(t < 7\))
Cycle recursion (\(t \ge 7\))
Let \(a = 1 - \alpha/2\):
Trigger
(in code, trigger = c1_ is the cycle value before writing the new cycle
into state).
Result: cycle \(= C_t\), trigger \(= T_t\).
When fillna=False and fewer than \(P\) samples have been processed, both
fields are NaN.
Implementation Notes
- Implemented in
src/rtta/indicator.cppinclass EhlersCyberCycle. - Result type:
EhlersCyberCycleResult(cycle,trigger). - Price lags
p1_,p2_,p3_; smooth lagss1_,s2_; cycle lagsc1_,c2_. - Batch helper:
batch_ehlers_cyber_cycle.
