HomodyneDiscriminator
Background
The homodyne discriminator is John Ehlers' classic method (from Rocket Science for Traders) for measuring the dominant cycle of a market — how many bars the price is currently swinging over. It treats price like a radio signal: it splits the series into in-phase and quadrature (90°-shifted) components, then reads how fast the phase is rotating to recover the cycle length, bar by bar. The output is a smooth, low-lag period that bounces around as the market speeds up and slows down.
Traders rarely plot the raw period on its own. Its main job is to drive adaptive indicators: feed the measured period into a variable-period RSI, stochastic, moving average and so on, and the indicator automatically lengthens in slow markets and shortens in fast ones. It is one of the lowest-lag cycle measurements available, which is exactly what you want when the period is going to control another calculation.
In the current toolbox the homodyne discriminator is the default engine
(engine 0) behind DominantCycle. Calling
DominantCycle( Price ) with no engine argument gives you exactly this
measurement. See Cycle Engines for the other engines
you can choose. The period is clamped to the 6–50 bar range.
How to call it
There is no separate HomodyneDiscriminator AFL function to call. The
homodyne discriminator is simply the default engine of
DominantCycle, so you reach this exact measurement by
calling DominantCycle with no engine argument (or with engine
0):
DominantCycle(Price, Engine = 0)
| Parameter | Description |
|---|---|
| Price | The price array the dominant-cycle period is measured from. The input must not contain empty/null values at the left edge of the data. |
| Engine | Optional. Leave it out (or pass 0) for this homodyne
reading. Other values select a different estimator — see
Cycle Engines. |
It returns a per-bar array holding the measured dominant-cycle period (in bars), smoothed and clamped to the 6–50 range.
Usage
The most common use is as a period adaptor for another indicator:
periods = DominantCycle( Close ); // engine 0 = homodyne discriminator
myRSI = VariablePeriodRSI( Close, periods );
Plot( myRSI, "Adaptive RSI", colorRed );
If you want to experiment with other cycle estimators (Burg, Kalman, Multitaper)
while keeping the same formula, just change the Engine argument on
DominantCycle — the default engine produces this same homodyne
reading.