- The MESA Stochastic applies John Ehlers' Roofing Filter as a preprocessing stage before computing a stochastic oscillator, then smooths the stochas...
The MESA Stochastic applies John Ehlers' Roofing Filter as a preprocessing stage before computing a stochastic oscillator, then smooths the stochastic output with a Super Smoother. The Roofing Filter removes both low-frequency trend components (via highpass) and high-frequency noise (via Super Smoother), isolating the dominant cycle. The stochastic calculation on this filtered data produces a clean 0-to-1 oscillator that responds to cycle turning points rather than trend or noise, with substantially reduced whipsaw compared to conventional stochastic indicators.
## Historical Context
John Ehlers introduced the MESA Stochastic in his 2013 book *Cycle Analytics for Traders*, as part of his systematic framework for applying digital signal processing to market data. The "MESA" prefix references Maximum Entropy Spectral Analysis, Ehlers' preferred technique for estimating dominant cycle periods. The key innovation is the Roofing Filter preprocessing: by bandpass-filtering the data before applying the stochastic calculation, the oscillator responds to cycle extremes rather than trend extremes. Conventional stochastic indicators on raw price tend to saturate at 0 or 100 during trends (the "stochastic pop" failure mode), but the Roofing Filter removes the trend component entirely, so the stochastic operates on stationary cycle data. Ehlers demonstrated that this produces fewer false signals in trending markets while maintaining responsiveness at genuine cycle turning points. The Super Smoother stages use 2-pole Butterworth-derived coefficients that provide superior smoothing characteristics compared to simple or exponential moving averages.
## Architecture & Physics
### Three-Stage Pipeline
1.**Stage 1: Roofing Filter** (Highpass + Super Smoother). The highpass is a 2-pole Butterworth filter that removes cycles longer than `hpLength`, eliminating trend. The Super Smoother is a 2-pole lowpass filter that removes cycles shorter than `ssLength`, eliminating noise. Together they form a bandpass that isolates the dominant cycle band.
2.**Stage 2: Stochastic on filtered data.** A standard highest-high / lowest-low stochastic over `stochLength` bars of the roofing-filtered output. Because the input is zero-mean (trend removed), the stochastic operates on cycle oscillations rather than trending prices.
3.**Stage 3: Super Smoother of stochastic.** The same 2-pole smoothing filter applied to the raw stochastic, removing stochastic noise while preserving the timing of overbought/oversold transitions. Output is clamped to $[0, 1]$.
### IIR Filter Coefficients
Both the highpass and Super Smoother stages use coefficients derived from 2-pole Butterworth prototypes: