Skip to main content
Track Adaptive Filter
9 / 9
Library

2018issue C0348-55

Assembling a recursive median oscillator as a two-stage adaptive filter

A recursive median is built as an exponential moving average of a five-bar median of the chosen price series. A high-pass stage then converts that result into a zero-centered oscillator meant to be compared with the relative strength index on the same chart, and with ordinary moving-average calculations that extreme observations can distort.

  • The recursive median stage is an exponential moving average of a five-bar median of the chosen price series, meant to resist extremes that distort ordinary averaging.
  • The first smoothing coefficient comes from a cosine-and-sine formula whose only free parameter is the low-pass period, which defaults to 12.
  • A high-pass stage with a period that defaults to 30, and a 0.707 scaling inside the same trigonometric formula, converts the recursive median into a zero-centered oscillator.
  • Implementations expose the low-pass period, high-pass period, and median window as configurable inputs, and the oscillator is meant to be compared with the relative strength index as an unfiltered baseline.
Entries in this reading3 entries

What the construction does

The recursive median stage is built as an exponential moving average of a five-bar median of the chosen price series. That median-first step is motivated as a way to remove extreme price or volume observations that distort ordinary averaging calculations.

A moving average, in this setting, is a conventional averaging calculation that is easily distorted by those extremes. The median-first construction is meant to resist that distortion.

The recursive median stage

The first stage takes a five-bar median of the chosen price series and applies an exponential moving average to that median. The first smoothing coefficient is computed from a cosine-and-sine formula whose only free parameter is the low-pass period, defaulting to 12.

An adaptive filter, as the term is used here, is a recursive smoother whose coefficients are computed from chosen lookback periods so the output can track a series with less lag than a simple average.

The high-pass stage

A second high-pass stage, parameterized by a high-pass period that defaults to 30, converts the recursive median into a zero-centered oscillator. The high-pass coefficient uses a 0.707 scaling inside the same trigonometric formula used for the low-pass coefficient.

Comparing the oscillator with familiar baselines

The resulting oscillator is intended to be compared with the relative strength index as an unfiltered baseline on the same chart. The relative strength index is a well-known bounded oscillator used here as that unfiltered comparison baseline for the recursive median construction.

A moving-average calculation on the same series remains the ordinary average that extreme price or volume observations can distort, which is the contrast the median-first construction is meant to provide.

Inputs the construction exposes

Implementations expose the low-pass period, high-pass period, and median window as configurable inputs, with the median window defaulting to 5.

Recursive median oscillator on daily SPY

A trader should see a zero-centered oscillator that jumps with the April 2017 thrust and slumps through the late-June air pocket, then works back toward the axis into late October. The path was read off the AmiBroker daily SPY pane (RMO 16, 40); the last print of -0.29 matches the on-chart label of -0.2879 for 26 October 2017.
A trader should see a zero-centered oscillator that jumps with the April 2017 thrust and slumps through the late-June air pocket, then works back toward the axis into late October. The path was read off the AmiBroker daily SPY pane (RMO 16, 40); the last print of -0.29 matches the on-chart label of -0.2879 for 26 October 2017.SPY · Daily · 2017-01-03T00:00:00.000Z to 2017-10-26T00:00:00.000Z

AmiBroker used a five-bar median with low-pass 16 and high-pass 40. Intermediate readings are approximate to one decimal; only the final labeled print is exact.

Educational research material, not investment advice. Historical source context does not establish present-day performance.
9 of 9 in the Adaptive Filter track
1991Track finished · Next track: Adaptive moving averageBuilding variable-length moving averages from partitioned price changes48 readings
All readings on this track · 9 readings
  1. 1982Constructing moving averages with weights, alignment, and adaptive lookbacks
  2. 1990Constructing adaptive filters from equal-weight averages
  3. 2000Cycle-scaled lookbacks for a channel-breakout rule
  4. 2000When charting code breaks the adaptive trendline
  5. 2001Nonlinear Ehlers filter construction from momentum and distance weights
  6. 2001How a fixed smoother becomes a living parameter surface
  7. 2005A three-part workshop for adaptive-filter length search
  8. 2010Rebuilding an exponential average as a bounded error-correcting filter
  9. 2018Assembling a recursive median oscillator as a two-stage adaptive filter
All 9 readings tagged Adaptive Filter
Also on Adaptive Filter5 readings