Skip to content
Wildflower
Join waitlist

Ehlers' recursive median, Reflex, Trendflex and universal oscillator in Studio

John Ehlers' recursive median filter and oscillator, Reflex, Trendflex and the universal oscillator.

Updated 29 November 2026 · 4 minute read

Five more of John Ehlers' indicators, each written out from the code he published with it. You can use each one in the Indicator condition block, as an Indicator signal and, when it settles quickly enough (below), in the condition exit. They work the same way in Backtest and in the Bot, and your indicator draws them on TradingView, NinjaTrader, MetaTrader 5, cTrader and Quantower.

The recursive median pair

  • Recursive median filter. The middle of the last five closes, so one wild candle can't drag it, then smoothed with a one-step average. Your length sets the smoothing: swings shorter than it are smoothed away. It is drawn on price.
  • Recursive median oscillator. That filter with its slow drift taken out by a two-step high-pass. Swings longer than the second length you choose are removed, so the line swings above and below 0. It reads in price, so a level is typed in ticks.

His code starts the filter at 0. Wildflower starts it at the first median, which settles sooner and gives the same line once settled.

Reflex and Trendflex

Both smooth the closes over half your length, then look back your length of candles.

  • Reflex draws a straight line from the smoothed value that many candles ago to now, and adds up how far the smoothed values sit from that line. It shows the turns in a swing.
  • Trendflex adds up how far now is from each of those smoothed values. It stays on one side of 0 while a trend runs.

Each sum is divided by the root of its own slow average square, so both are measured against their own recent size rather than in price.

The universal oscillator

The change in the close over two candles, smoothed over your length, then divided by its own recent peak. The peak fades by a little under 1% each candle and jumps up to any bigger swing, so the line runs from minus 1 to 1.

How a row reads them

A row asks the recursive median filter about the close above or below it or crossing it, and the line rising, falling or turning. The others it asks above or below a level you type, crossing it, and the line rising, falling or turning.

When it has a value

Each one feeds back on itself, so its first values depend on where it started. Each waits until that start has faded to under a millionth, so a Bot that starts later reads the same number as one that never stopped. The median filter needs a few dozen candles at short lengths, more at long ones. Reflex and Trendflex also wait for their slow average square: 354 candles at length 3, 415 at length 18 and 1,164 at length 200. The universal oscillator's peak fades slowly, so it needs at least 1,550 candles.

A condition exit reads the last 512 candles, so a row that needs more can't be an exit: the universal oscillator at any length, Reflex and Trendflex from about length 42, and the median oscillator with a long second length. The Bot loads 30 days before it starts, so a row that needs more than that is refused on longer candles: the universal oscillator on candles of 20 minutes or more (and on shorter ones at long lengths), and Reflex and Trendflex on hourly candles from about length 25.

A row that needs more candles than your warmup holds is refused when you put the strategy on an account.

Every number is yours

Each row asks for exactly the numbers its indicator reads: the length, and for the oscillator the length of swing it starts to take out. Nothing has a default.

What's next

Ehlers' other filters and cycles.