Homodyne Moving Average is a moving average that automatically adjusts to market conditions, built on the basis of a homodyne discriminator — one of the most advanced developments by John Ehlers, originating directly from radar and communication systems.
In radio engineering, a homodyne receiver “mixes” the incoming signal with its phase‑shifted copy to isolate the phase difference and instantly calculate the current wave frequency. On the stock chart, this allows you to measure in real time the dominant cycle (the wavelength in bars) on which the market is currently breathing, and automatically adjust the moving average to it.
How does this indicator work inside?
Hilbert Transform: The code decomposes the price graph into two components — in-phase (I, the cosine analogue) and quadrature (Q, the sine analogue shifted by 90°). This allows you to represent the price movement as a rotating vector (phasor).
Homodyne mixing: the program multiplies the vector of the current bar by the complex conjugate of the vector of the previous bar. As a result, we get the angle by which the market wave has rotated over one bar.
Wave length calculation: knowing the phase rotation angle (MathArctan), we divide a full circle (2π) by this angle and get the exact number of bars in the current market cycle (SmoothPeriod).
Self‑adjustment: the obtained period is immediately passed to the moving average formula. If a fast cycle begins in the market (for example, 10–12 bars), the average itself accelerates. If the cycle stretches, for example, to 40 bars, the average slows down, ignoring minor pullbacks.
The main advantage of the Homodyne Moving Average over classic averages (SMA, EMA, WMA) is its automatic adjustment to the current “frequency” of the market without manually iterating through periods, which eliminates the main conflict of conventional moving averages between lag and false signals.
Classic moving averages have a fixed period (for example, 20 or 50). However, the market is constantly changing phases: a calm sideways trend is followed by a sharp impulse, and long trend waves are replaced by short sawtooth waves.
Key differences and advantages:
1. Automatic measurement of wave length (no “fitting”)
Regular MA: you set the period yourself “by eye” or via an optimizer, but after a week the nature of the market changes, and the settings stop working.Homodyne MA: using the Hilbert transform, the indicator itself measures the current dominant cycle in the bars and recalculates its smoothing period on each tick.
2. Minimum phase lag at reversals
Regular MA: simply averages past prices. The longer the period, the more the line lags behind the price at peaks and troughs.
Homodyne MA: analyzes the rate of change of the wave phase. As soon as the market cycle begins to unfold, the phase angle changes, and the average reacts to the turning point almost immediately, without waiting for a history of new prices to accumulate.
3. Resistance to market noise in a flat
Regular MA: if you set a short period (for example, 10), it catches impulse movements well, but in a sideways market it starts to “chop” the price and produce dozens of false crossovers.
Homodyne MA: a preliminary 4‑point FIR filter and period change rate limiters cut out high‑frequency spikes (random spikes), preventing the line from jerking with every noisy bar.
4. Natural trend filtering during cycle calculation
Conventional oscillators and averages get stuck on prolonged trends. Inside the homodyne discriminator, there is a Detrender block that mathematically subtracts the linear trend before measuring the wave — so the indicator continues to correctly detect internal cycles even during strong, non‑reverting movement.
Input parameters:
InpMinPeriod // Minimum wave period (noise protection)
InpMaxPeriod // Maximum wave period (anti‑freeze protection)
InpAlphaFactor // Adaptation coefficient (0.1 — smoother, 1.0 — faster)
InpAppliedPrice // Price method