quantwave_core/indicators/
cycle.rs1use crate::indicators::metadata::IndicatorMetadata;
2pub use crate::indicators::incremental::hilbert_ta::{
3 HT_DCPERIOD, HT_DCPHASE, HT_PHASOR, HT_SINE, HT_TRENDMODE,
4};
5
6pub const HT_DCPERIOD_METADATA: IndicatorMetadata = IndicatorMetadata {
7 name: "Hilbert Transform - Dominant Cycle Period (HT_DCPERIOD)",
8 description: "Identifies the period of the dominant cycle in the price data using the Hilbert Transform.",
9 usage: "Use to dynamically adjust the lookback periods of other indicators (e.g., adaptive moving averages). Knowing the current dominant cycle length allows for more accurate smoothing and trend detection.",
10 keywords: &["cycle", "hilbert", "adaptive", "dsp"],
11 ehlers_summary: "John Ehlers popularized the use of the Hilbert Transform to identify the dominant cycle in financial time series. The DCPERIOD indicator tracks the length of this cycle in bars, providing a crucial parameter for creating market-responsive technical indicators that adapt to changing volatility. — Rocket Science for Traders",
12 params: &[],
13 formula_source: "https://www.tradingview.com/support/solutions/43000502011-hilbert-transform-dominant-cycle-period-ht-dcperiod/",
14 formula_latex: r#"
15\[
16\text{DCPERIOD}_t = \text{Recalculated Dominant Cycle using Hilbert Transform}
17\]
18"#,
19 gold_standard_file: "ht_dcperiod.json",
20 category: "Ehlers DSP",
21};
22
23pub const HT_DCPHASE_METADATA: IndicatorMetadata = IndicatorMetadata {
24 name: "Hilbert Transform - Dominant Cycle Phase (HT_DCPHASE)",
25 description: "Calculates the phase angle (0 to 360 degrees) of the dominant cycle identified by the Hilbert Transform.",
26 usage: "Use to identify the current position within a market cycle. It is the core component for generating the Hilbert Sine Wave indicator, which signals trend vs. cycle regimes.",
27 keywords: &["cycle", "hilbert", "phase", "dsp"],
28 ehlers_summary: "The Dominant Cycle Phase represents the instantaneous position within a detected cycle. By measuring the phase angle, traders can determine if the market is at a peak, trough, or mid-cycle, enabling more precise timing for entry and exit signals. — Rocket Science for Traders",
29 params: &[],
30 formula_source: "https://www.tradingview.com/support/solutions/43000502010-hilbert-transform-dominant-cycle-phase-ht-dcphase/",
31 formula_latex: r#"
32\[
33Phase = \arctan\left(\frac{\text{Quadrature}}{\text{InPhase}}\right)
34\]
35"#,
36 gold_standard_file: "ht_dcphase.json",
37 category: "Ehlers DSP",
38};
39
40pub const HT_PHASOR_METADATA: IndicatorMetadata = IndicatorMetadata {
41 name: "Hilbert Transform - Phasor Components (HT_PHASOR)",
42 description: "Outputs the In-Phase and Quadrature components of the signal, which are used to calculate phase and amplitude.",
43 usage: "Use as building blocks for custom DSP indicators. The In-Phase component is the signal itself, while the Quadrature component is shifted by 90 degrees.",
44 keywords: &["cycle", "hilbert", "phasor", "dsp"],
45 ehlers_summary: "The Phasor components (In-Phase and Quadrature) are the fundamental outputs of the Hilbert Transform. They allow for the decomposition of a signal into its vector representation, which is essential for advanced cycle analysis and the creation of lag-free filters. — Rocket Science for Traders",
46 params: &[],
47 formula_source: "https://www.tradingview.com/support/solutions/43000502012-hilbert-transform-phasor-components-ht-phasor/",
48 formula_latex: r#"
49\[
50\text{Result} = (InPhase, Quadrature)
51\]
52"#,
53 gold_standard_file: "ht_phasor.json",
54 category: "Ehlers DSP",
55};
56
57pub const HT_SINE_METADATA: IndicatorMetadata = IndicatorMetadata {
58 name: "Hilbert Transform - Sine Wave (HT_SINE)",
59 description: "An indicator that plots a sine wave and a lead-sine wave (shifted by 45 degrees) to identify cyclical turns.",
60 usage: "Use to identify cycle turning points and trend regimes. When the two waves are separated and rhythmic, the market is in a cycle; when they are compressed or crossover erratically, the market is in a trend.",
61 keywords: &["cycle", "hilbert", "sine", "dsp"],
62 ehlers_summary: "The Hilbert Sine Wave is one of John Ehlers' most famous contributions. It provides a clear visual indication of market cycles. Crossovers of the Sine and Lead-Sine waves provide high-probability entry points in ranging markets while identifying when a strong trend has taken over. — Rocket Science for Traders",
63 params: &[],
64 formula_source: "https://www.tradingview.com/support/solutions/43000502013-hilbert-transform-sine-wave-ht-sine/",
65 formula_latex: r#"
66\[
67Sine = \sin(Phase) \\ LeadSine = \sin(Phase + 45^\circ)
68\]
69"#,
70 gold_standard_file: "ht_sine.json",
71 category: "Ehlers DSP",
72};
73
74pub const HT_TRENDMODE_METADATA: IndicatorMetadata = IndicatorMetadata {
75 name: "Hilbert Transform - Trend vs. Cycle Mode (HT_TRENDMODE)",
76 description: "A binary indicator that determines if the market is currently in a trending state (1) or a cyclical state (0).",
77 usage: "Use as a master filter for strategy selection. Deploy trend-following tools when TRENDMODE is 1, and mean-reversion tools when TRENDMODE is 0.",
78 keywords: &["cycle", "trend", "hilbert", "regime-detection", "dsp"],
79 ehlers_summary: "Determining the current market regime is the 'holy grail' of technical analysis. The HT_TRENDMODE indicator uses the rate of change of the dominant cycle phase to distinguish between trending and ranging price action, allowing traders to avoid 'whipsaws' in non-conducive environments. — Rocket Science for Traders",
80 params: &[],
81 formula_source: "https://www.tradingview.com/support/solutions/43000502014-hilbert-transform-trend-vs-cycle-mode-ht-trendmode/",
82 formula_latex: r#"
83\[
84\text{TRENDMODE} = \begin{cases} 1 & \text{if trend detected} \\ 0 & \text{if cycle detected} \end{cases}
85\]
86"#,
87 gold_standard_file: "ht_trendmode.json",
88 category: "Ehlers DSP",
89};