Loading…

Cycle Adaptive Stochastic

A classic Stochastic's fixed lookback is a compromise chosen once and never revisited: too long for a market currently cycling quickly, too short for one cycling slowly. This indicator instead measures the market's own dominant cycle length bar by bar with Ehlers' Hilbert transform technique - 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 - and drives %K's window from that measurement, the same core estimator this catalogue's CycleAdaptiveRsi uses. The one deliberate difference from CycleAdaptiveRsi is that this indicator uses the FULL measured period for %K rather than half of it. CycleAdaptiveRsi halves the period because an up/down bar-count oscillator over-smooths at a full-period window (Ehlers' own published guidance); a Stochastic instead needs to sample a genuine complete swing of the range to find meaningful highs and lows, so shrinking the window below the full measured cycle would start clipping the very extremes %K is meant to locate. %D is then a plain simple average of %K, the same signal-line convention as a standard Stochastic. 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 a neutral 50/50 %K/%D rather than left blank, identical seeding approach to CycleAdaptiveRsi in this catalogue. - The dominant-cycle estimate is smoothed and clamped to move at most 50% per bar 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) still produces a period estimate, since the Hilbert transform always returns some phase rotation rate; 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 Stochastic-family oscillator does.

Indicator · MT5 · v1.0 · Free

About Cycle Adaptive Stochastic

Cycle Adaptive Stochastic is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Min period, Max period and D period. MQL source code included.

Files in the download: CycleAdaptiveStochastic.ex5, CycleAdaptiveStochastic.mq5, CycleAdaptiveStochastic.txt.

Settings

SettingDefaultWhat it does
Min period6Floor on the measured dominant cycle, in bars
Max period50Ceiling on the measured dominant cycle, in bars
D period3Simple-average length of the %D signal line
AlertstrueAlert once per closed bar on an 80/20 threshold cross

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Stochastic · Oscillator · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria