Real-time chart analysis needs deterministic updates per bar and explicit handling of warm-up periods. CCOR addresses this by implementing Computes Ehlers Correlation Cycle — extracts cycle phase via Pearson correlation of price with parameterized inputs and direct state progression.
This implementation favors streaming execution over batch recomputation. The trade-off is more attention to state initialization, but latency stays predictable when charts scale.
Computes Ehlers Correlation Cycle — extracts cycle phase via Pearson correlation of price
| Parameter | Purpose |
|---|---|
source |
Series to analyze |
period |
Presumed dominant cycle wavelength |
threshold |
Angle rate-of-change threshold (degrees) for trend/cycle state detection |
- [real, imag, angle, state] — correlation components, phasor angle, market state (+1/-1/0)
| Input variable | Type | Configuration |
|---|---|---|
i_period |
input.int |
default: 20, label: "Period" |
i_threshold |
input.float |
default: 9.0, label: "State Threshold (degrees)" |
i_source |
input.source |
default: close, label: "Source" |
- Declared optimization: O(period) per bar for dual correlation loops; O(1) state variables
- Streaming model: single-pass update on each new bar.
- Warm-up behavior: outputs can be unstable until enough samples satisfy
period. - Memory model: state is kept in Pine series context rather than external buffers.
Streaming logic keeps incremental cost stable, but initialization and edge-case handling become first-class concerns. That is a deliberate choice: predictable execution beats opaque recalculation spikes in live charts.
- Open the script in TradingView and confirm it compiles under Pine Script v6.
- Validate warm-up behavior on sparse data and short histories.
- Compare output against a trusted reference implementation for the same parameters.
- Confirm parameter bounds reject invalid values without silent fallback.
- Source code:
indicators/cycles/ccor.pine - Documentation file:
indicators/cycles/ccor.md - GitHub source view: https://github.com/mihakralj/QuanTAlib/blob/main/indicators/cycles/ccor.pine
- GitHub documentation view: https://github.com/mihakralj/QuanTAlib/blob/main/indicators/cycles/ccor.md