4.0 KiB
Stochastic Roofing Slow Professional
1. Summary (Introduction)
The Stochastic Roofing Slow indicator is a powerful oscillator based on the concepts of John Ehlers. It combines two advanced filtering techniques to create a superior version of the classic Slow Stochastic Oscillator.
The indicator addresses a common problem with the standard Stochastic: its tendency to get "stuck" or "pinned" at overbought (100) or oversold (0) levels during strong trends, making it unreliable for generating signals.
This is achieved by calculating the Stochastic not on the raw price, but on a pre-filtered data series generated by Ehlers' Roofing Filter. The Roofing Filter removes both the long-term trend and the high-frequency noise from the price, leaving only the core, tradable market cycles.
The result is a smooth, zero-mean Stochastic that provides clear, cyclical signals even within a trending market.
2. Mathematical Foundations and Calculation Logic
The indicator uses a multi-stage process, chaining a Roofing Filter and a Slow Stochastic Oscillator.
Calculation Steps (Algorithm)
- Roofing Filter Calculation: The source price is first passed through a two-stage Roofing Filter (a High-Pass filter followed by a SuperSmoother filter). This creates a smooth, detrended, zero-mean output representing the market's cycles.
- Raw %K Calculation: A standard Stochastic %K value is calculated, but instead of using the
High,Low, andCloseof the price, it uses the Highest, Lowest, and Current Value of the Roofing Filter's output over the%K Period. - %K Smoothing (Slowing): The raw %K values are then smoothed using a Simple Moving Average over the
Slowingperiod. This result is the final %K line (Slow %K). - %D Smoothing: The final %K line is smoothed again using a Simple Moving Average over the
%D Periodto create the %D signal line.
3. MQL5 Implementation Details
- All-in-One Calculator (
Stochastic_Roofing_Calculator.mqh): The entire complex, multi-stage calculation (Roofing Filter + Stochastic) is encapsulated within a single, dedicated calculator class. - Heikin Ashi Integration: An inherited
_HAclass allows the initial Roofing Filter calculation to be performed seamlessly on smoothed Heikin Ashi data. - Stability via Full Recalculation: The calculation involves multiple chained, state-dependent filters. To ensure absolute stability, the indicator employs a full recalculation on every
OnCalculatecall.
4. Parameters
- Roofing Filter Settings:
High-Pass Period: The period for the trend-removal filter. Ehlers' default is 48.SuperSmoother Period: The period for the noise-smoothing filter. Ehlers' default is 10.
- Stochastic Settings:
%K Period: The lookback period for the Stochastic calculation.%D Period: The period for the final signal line smoothing.Slowing: The period for the initial smoothing of the raw %K value. This is the key parameter that defines it as a "Slow" Stochastic.
- Source Settings:
Applied Price: The source price for the initial Roofing Filter calculation.
5. Usage and Interpretation
This indicator should be used as an enhanced Stochastic Oscillator for identifying cyclical turning points.
- Overbought / Oversold Signals: The primary signals are the classic Stochastic levels.
- Buy Signal: The %K line crosses up from below the oversold level (e.g., 20).
- Sell Signal: The %K line crosses down from above the overbought level (e.g., 80).
- Key Advantage: Unlike a standard Stochastic, these signals are reliable even in a trending market, as the Roofing Filter has removed the trend's distorting effect. The indicator will oscillate clearly instead of getting pinned to the extremes.
- Signal Line Crossover: Crossovers of the %K and %D lines can be used for earlier entry or exit signals, just like with a standard Stochastic.
- Divergence: Divergences between the indicator and the price are powerful reversal signals.