Discussing the article: "Digital Signal Processing for Traders (Part 2): The Dominant Cycle, MAMA, and a Regime-Switching Expert Advisor"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Digital Signal Processing for Traders (Part 2): The Dominant Cycle, MAMA, and a Regime-Switching Expert Advisor.
In Part 2 we measure the market's dominant cycle using Ehlers' Hilbert-transform homodyne discriminator and wrap it as an indicator. We then build the MESA Adaptive Moving Average (MAMA) and its follower FAMA from that phase information. Finally, we combine MAMA/FAMA with the Even Better Sinewave to form a regime-switching Expert Advisor and test it on EURUSD in the Strategy Tester, giving you a complete, reproducible MQL5 implementation.
Every adaptive tool in Ehlers' toolkit rests on one measurement: how long is the cycle that currently dominates price? If the market is swinging with a roughly 20-bar rhythm, an oscillator tuned to 20 bars reads it cleanly, while one tuned to 10 or 40 does not. The trouble is that this dominant period is not constant. It breathes, stretching in quiet markets and compressing in fast ones, so it has to be measured continuously rather than assumed. That measurement is the job of the CyclePeriod class, and it is the engine that MAMA will reuse in the next section.
The idea, without the derivation. Think of the cycle component of price as a wave. At any instant a wave has a phase, an angle on the circle that tells you where in its swing it is: rising through zero, at the top, falling through zero, at the bottom. If you could read that phase on every bar, then the amount the phase advances from one bar to the next tells you the frequency, and the frequency inverted is the period. So measuring the dominant cycle reduces to measuring how fast the phase is turning.
To read phase you need two versions of the wave: the wave itself, called the in-phase component, and a copy shifted by exactly 90 degrees, called the quadrature component. With both in hand, the phase is just the arctangent of quadrature over in-phase, exactly the way you would read an angle from its sine and cosine. The device that produces a 90-degree-shifted copy of a signal is the Hilbert transform, and Ehlers approximates it with a short 7-tap filter.
Author: Adeolu Kayode Gbadebo