Cycle Adaptive Rsi
Wilder's fourteen-bar RSI window is a fixed compromise: too long for a market currently cycling quickly, too short for one cycling slowly, and never actually matched to either because it never looks. Ehlers' adaptive oscillator family instead measures the market's own dominant cycle length bar by bar and drives the oscillator's window from that measurement, so the lookback tracks what the market is actually doing rather than a constant chosen once and never revisited. The dominant-cycle estimate here is the same Hilbert transform technique this catalogue's MAMA/FAMA indicator uses: a smoothing and detrending FIR filter turns price into an in-phase/quadrature pair, a homodyne discriminator reads how fast the phase between successive bars is rotating, and that rotation rate converts directly to a period in bars. Ehlers' own published guidance for RSI/CCI-style level oscillators (as opposed to trend lines like MAMA) is to use half the measured dominant cycle as the window, since a full-period window over-smooths an indicator built from counting up versus down bars. That halved, clamped period is what this file uses to compute a plain RSI average each bar - recomputed as a fresh windowed average rather than a Wilder-style running smooth, because the window length itself changes from bar to bar and a running smooth has no consistent meaning across a length change. Notes and limitations - The Hilbert transform estimator is itself recursive and reaches roughly ten bars into history before its FIR taps are fully populated; those early bars are seeded at a flat 15-bar cycle guess and an RSI of 50 rather than left blank. - The dominant-cycle estimate is smoothed and clamped to move at most 50% per bar specifically to stop noise spikes in the phase measurement from producing an implausible one-bar period jump - this bounds the adaptive window's reaction speed by design, not an oversight. - A genuinely non-cyclic instrument (a strong one-directional trend with no measurable periodicity) will still produce a period estimate, since the Hilbert transform always returns some phase rotation rate; the resulting RSI window is not meaningless in that case, but it is not measuring a real market cycle either - treat a long stretch pinned near InpMinPeriod or InpMaxPeriod as a sign the market is not currently cyclic rather than as a fault. - This measures cycle length, not cycle direction - it does not replace a trend filter, and can still whipsaw inside a genuinely trending market the way any RSI-family oscillator does.
Indicator · MT5 · v1.0 · Free
About Cycle Adaptive Rsi
Cycle Adaptive Rsi is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Min period, Max period and Alerts. MQL source code included.
Files in the download: CycleAdaptiveRsi.ex5, CycleAdaptiveRsi.mq5, CycleAdaptiveRsi.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Min period | 6 | Floor on the measured dominant cycle, in bars |
| Max period | 50 | Ceiling on the measured dominant cycle, in bars |
| Alerts | true | Alert once per closed bar on a 30/70 threshold cross |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: RSI · Oscillator · Alerts · MT5 Indicator · MQL5 Source Code