Hilbert Huang Phase Analyzer MT4
- Indicatori
-
Anthony Cooke
Quantitative Systems Architect and C++, Python, MQL5, MQL4, and Pine Script developer specializing in non-repainting mathematical indicators, Expert Advisors, and statistical strategy audits. I combine industrial quality-control engineering and Applied Mathematics with multi-physics market modeling - Versione: 1.0
- Attivazioni: 5
OVERVIEW AND SCIENTIFIC ORIGIN
The Hilbert Huang Phase Analyzer is a cycle-timing and instantaneous-phase indicator engineered from Nonlinear Signal Processing and Empirical Mode Decomposition (the Huang et al. Hilbert-Huang Transform [HHT], adapted into a 100 percent causal real-time digital signal processor). Traditional oscillators use fixed-period lookbacks that lag sharply whenever market swing rhythm speeds up or slows down, and they fail during strong directional trends.
This strictly causal, non-repainting indicator sifts raw log-prices into a zero-mean Intrinsic Mode Function, computes live Hilbert quadrature components, tracks the changing Dominant Cycle Period automatically, and maps every market swing around a color-coded 4-quadrant 360-degree phase clock protected by a built-in Trend-vs-Cycle guard across Gold (XAUUSD), Major Forex pairs, and US Indices from M15 to Weekly charts.
THREE-STEP CAUSAL DSP ENGINE
1. Causal 2-Stage Butterworth Sifting: Applies dual 2-pole Butterworth SuperSmoother filters—stripping fast tick noise below InpMinPeriod (default 8 bars) and slow macro trend drift above InpMaxPeriod (default 40 bars)—followed by causal mean removal to isolate a clean, zero-mean Intrinsic Mode Function (IMF1) with zero repainting.
2. Gain-Compensated FIR Hilbert Quadrature: Projects IMF1 into orthogonal analytic components (In-Phase I and Quadrature Q) using a causal 7-tap FIR Hilbert filter with adaptive frequency-gain compensation.
3. Homodyne Dominant Cycle and Phase Compensation: Measures instantaneous angular frequency cleanly via complex-conjugate homodyne discrimination without branch-cut jumps to derive the live Dominant Cycle Period (in bars), compensates for the 3-bar FIR group delay to output real-time Instantaneous Phase (0 to 360 degrees), and modulates the phase sine wave by rolling IMF RMS envelope confidence (InpEnvPeriod = 55).
HOW TO READ THE 4-QUADRANT 360-DEGREE CYCLE CLOCK
Subwindow Scale (-105.0 to +105.0, dashed reference levels at +60.0, 0.0, and -60.0):
Every coherent market swing rotates sequentially through four color-coded phase quadrants:
- Q1 (0 to 90 deg, MediumSeaGreen — Phase_Q1_Bull_Impulse): Bullish cycle impulse accelerating upward from zero toward the cycle peak.
- Q2 (90 to 180 deg, Gold — Phase_Q2_Peak_Rollover + Magenta Top Dot): Peak rollover and distribution as upward cycle energy exhausts and curls off the top.
- Q3 (180 to 270 deg, Crimson — Phase_Q3_Bear_Impulse): Bearish cycle impulse accelerating downward from zero toward the cycle trough.
- Q4 (270 to 360 deg, DeepSkyBlue — Phase_Q4_Trough_Turn + Lime Bottom Dot): Trough turn and accumulation as downward momentum exhausts and curls upward off the bottom.
- WhiteSmoke Smooth Line (Hilbert_Phase_Sine): Envelope-modulated instantaneous phase sine wave (-100% to +100%).
- Lime Dot (Cycle_Bottom_Turn) and Magenta Dot (Cycle_Top_Turn): Strictly alternating reversal-locked cycle markers plotted when entering Q4 below -InpTurnThresh (-35%) or entering Q2 above +InpTurnThresh (+35%).
DARK TELEMETRY HUD BOX AND TREND-VS-CYCLE GUARD
Anchored in the upper-right subwindow inside a solid dark slate panel with a DodgerBlue border:
- Line 1 (HILBERT PHASE): Active phase quadrant and exact live phase angle (0 to 360 deg), color-matched to the active histogram quadrant.
- Line 2 (DOM CYCLE and SINE WAVE): Live homodyne-measured Dominant Cycle Period in chart bars alongside the envelope-weighted phase sine percentage.
- Line 3 (MODE and T/C RATIO): Built-in Trend-vs-Cycle guard comparing slow macro trend displacement against cycle amplitude. Aqua below 1.50x reads CYCLIC COHERENT (clean swing environment suited for cycle turns); Gold at 1.50x and above warns TREND DOMINANT (CYCLE DAMPED) so traders do not fade runaway directional trends.
- Line 4 (PHASE ACTION): Direct tactical posture matching the live quadrant (MOMENTUM LONG, PEAK DISTRIBUTION / TAKE PROFIT, MOMENTUM SHORT, or TROUGH ACCUMULATION / REVERSAL).
PRACTICAL USAGE
Cyclic Swing Timing (When HUD Line 3 Reads CYCLIC COHERENT, T/C < 1.50x):
Watch DeepSkyBlue Q4 bars printing a Lime Cycle_Bottom_Turn dot followed by a transition into MediumSeaGreen Q1 bars (0 to 90 deg) for long swing entries; tighten stops or take profit when bars flip to Gold Q2 with a Magenta Cycle_Top_Turn dot, and watch Gold-to-Crimson Q3 transitions for short swings.
Trend Protection (When HUD Line 3 Warns TREND DOMINANT, T/C >= 1.50x):
Do not counter-trade Q2 or Q4 reversal dots against the dominant macro trend. Instead, use Q4 troughs strictly as pullback re-entry timing inside an uptrend, or Q2 peaks strictly as pullback timing inside a downtrend.
TECHNICAL SPECIFICATIONS AND INPUT PARAMETERS
Calculation Engine:
100 percent causal bar-by-bar digital signal processor with zero repainting, zero backpainting, and zero external DLL calls. Short name: HHT_Phase(8,40).
Core Input Parameters:
- InpMinPeriod (Default: 8, Range 4 to 25): High-frequency noise cutoff period for the fast Butterworth SuperSmoother.
- InpMaxPeriod (Default: 40, Range 20 to 120): Low-frequency macro trend cutoff period for the slow Butterworth SuperSmoother.
- InpEnvPeriod (Default: 55): Rolling IMF RMS window controlling scale-invariant envelope confidence.
- InpTurnThresh (Default: 35.0, Range 15.0 to 80.0): Minimum sine-wave amplitude (%) required to plot alternating Lime bottom and Magenta top turn dots.
- InpShowHUD (Default: true): Toggles the 4-line dark telemetry panel (bypassed automatically during optimization).
Expert Advisor Integration (iCustom Buffers):
Buffer 0: Phase_Q1_Bull_Impulse | Buffer 1: Phase_Q2_Peak_Rollover | Buffer 2: Phase_Q3_Bear_Impulse | Buffer 3: Phase_Q4_Trough_Turn | Buffer 4: Hilbert_Phase_Sine (Smooth -100 to +100 cycle wave) | Buffer 5: Cycle_Bottom_Turn | Buffer 6: Cycle_Top_Turn | Buffer 7: HHT_Phase_Deg (Hidden continuous 0.0 to 360.0 degree phase angle for automated cycle logic).
TIMEFRAME AND ASSET CALIBRATION
Default settings (8 to 40 bar cycle band, 55 envelope period, 35% turn threshold) work cleanly across XAUUSD, Major Forex pairs, and US Indices from M15 to Weekly:
- Fast Intraday Cycles (M15 to M30): Keep InpMinPeriod at 6 to 8 and narrow InpMaxPeriod to 28 to 34 to focus on shorter intraday session waves.
- Multi-Day Swing Cycles (H4 to Daily/Weekly): Keep InpMinPeriod at 8 to 10 and expand InpMaxPeriod to 40 to 60 with InpTurnThresh at 40% to 50% to isolate only clean primary swing peaks and troughs.
- High-Volatility Instruments (XAUUSD, US30, NAS100): Raise InpMinPeriod to 10 to filter sharp intraday wick jitter while keeping HUD Line 3 (T/C Ratio) visible to respect strong session trends.
----Trading on MetaTrader 5 instead of MetaTrader 4? The identically engineered MetaTrader 5 edition of Hilbert Huang Phase Analyzer is published on my MQL5 Seller Profile with the exact same thumbnail, causal Butterworth IMF sifting, Hilbert quadrature engine, dark telemetry HUD, and parameter set. Visit my seller profile to access the MT5 version.
