2014issue C0161-62
Constructing a roofed stochastic from highpass and lowpass stages
A historical workflow links a two-pole lowpass smoother, a roofing filter that highpass-filters closes and then reapplies that lowpass, and a stochastic oscillator computed on the roofed series.
- The construction presents three linked stages: a two-pole lowpass smoother, a roofing filter that runs a highpass stage before that same lowpass, and a stochastic oscillator on the roofed series.
- Lowpass recursive coefficients are formed from an exponential-cosine pair at period 10 and arranged so the three weights form a unity-gain recursion.
- After the highpass stage, the roofing construction reapplies the same period-10 two-pole lowpass to the highpass series rather than to raw closes.
- The stochastic stage defaults to length 20, initializes its range from the highest already-filtered value, and both filter stages return zero when fewer than two historical samples are present.
Three linked stages
The construction presents three linked stages: a two-pole lowpass smoother, a roofing filter that runs a highpass stage before that same lowpass, and a stochastic oscillator computed on the roofed series.
A lowpass-filter is a two-pole recursive smoother whose weights come from an exponential-cosine pair at a chosen period and are applied to averaged adjacent samples. A highpass-filter is a recursive stage that attenuates slow drift by combining a second difference of closes with lagged highpass outputs. A roofing-filter is a two-stage construction that highpass-filters a price series and then lowpass-smooths that highpass output, leaving a mid-band residual. A stochastic-oscillator is a range-normalized transform that locates the current filtered value between the highest and lowest filtered values over a chosen lookback.
Lowpass coefficients and the standalone smoother
Lowpass coefficients are formed from an exponential of -1.414 times 3.14159 divided by 10 and a cosine of 1.414 times 180 divided by 10, then arranged so the three weights form a unity-gain recursion. Each recursive-coefficient is a fixed weight computed from trigonometric and exponential expressions of a period, then reused at every bar.
The standalone lowpass stage applies its feedforward weight to the average of the current and previous close and then adds two lagged outputs of the filter. The lowpass implementation returns zero when fewer than two historical samples are present, encoding a minimum lookback for the recursive terms.
Roofing highpass, then the same lowpass
The roofing highpass first computes an alpha from cosine and sine of 0.707 times 360 divided by 48, then combines a second difference of closes with two recursive highpass lags.
After the highpass stage, the roofing construction reapplies the same period-10 two-pole lowpass to the highpass series rather than to raw closes. The roofing implementation also returns zero when fewer than two historical samples are present.
Stochastic stage on the roofed series
The stochastic stage accepts a length input that defaults to 20 and initializes its range from the highest value of the already-filtered series. The oscillator then locates the current filtered value between the highest and lowest filtered values over that lookback.
A worked chart example plots the roofing filter together with the stochastic oscillator on a single price series.
Roofed MESA Stochastic on daily Google, 2012–2013

The Tradecision listing fixes the roofing highpass at 48 bars, the two-pole lowpass at 10 bars, and the stochastic lookback at 20. Y readings are to the nearest 0.05 because the pane is scaled 0–1 with 0.2 grid lines.
All readings on this track · 7 readings
- 2006Constructing lowpass, highpass, and finite impulse response filters from one recurrence
- 2006Constructing a trend filter from a cycle-length moving average and a highpass residual
- 2014Constructing a roofed stochastic from highpass and lowpass stages
- 2014The dual-K highpass roofing filter is unfinished until three choices are written together
- 2015Constructing a decycler from high-pass cancellation
- 2015Constructing decycler oscillators from highpass and bandpass filters
- 2020Finite-memory truncation for cycle filters