Recursive Median Oscillator by John Ehlers

Recursive Median Oscillator by John Ehlers

This is the the recursive median Oscillator featured by John Ehlers in the march 2017 issue of Trader’s Tips.

In “Recursive Median Filters” in this issue, author John Ehlers presents an approach for filtering out extreme price and volume data that can throw off typical averaging calculations. Ehlers goes on to present a novel oscillator using this technique, comparing its response to the well-known RSI. He notes that by being able to smooth the data with the least amount of lag, the recursive median oscillator may give the trader a better view of the bigger picture.

 

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. JMat45 • 03/08/2018 #

    Thanks, Despair. Wasn’t it the most recent issue though, i.e. March 2018?

  2. Despair • 03/08/2018 #

    You are right, it is from March 2018. 🙂

  3. Bard • 03/08/2018 #

    See this PRT link for more details from Stocks & Commodities Magazine:
    https://www.prorealcode.com/topic/ehlers-mesa-indicators-constantly-reload-recalculate/#post-65420
    (submit link button wouldn’t open)

  4. Bard • 03/08/2018 #

    From the url link #post-65420 above but without the chart image:

    Stocks & Commodities V. 36:03 (8–11): Recursive Median Filters by John F. Ehlers

    Impulsive noise spikes or extreme price or volume data are not unusual in the nancial markets and these extreme values can throw off your averaging calculations. How can you set up a data lter to re- move these extreme price movements? This STOCKS & COMMODITIES Contributing Editor shows you a way to handle this by using a lter that discards all data except the median value.

    Median lters are best applied to remove impulsive or spiking types of noise. Rather than averaging the spike into the lter out- put, median lters simply ignore the spike. Median lters are routinely used for pro-

    cessing photographs and video because they preserve the sharp edges in the images rather than smoothing them as is done by averaging lters. Median lters have the unique characteristic of being idempotent, that is, if you repeatedly perform median ltering on a time waveform, the output rapidly converges to being exactly the input waveform except for com- putational lag. That a price waveform converges to a core waveform has some interesting philosophical rami cations for trading.

    HOW SO?

    Median lters are nonlinear. Since a median lter is not a convolution lter, it cannot be suitably represented in the Fourier frequency domain. Also, its output is not differentiable and therefore does not have a Taylor series expansion. This precludes curve- tting by a higher-order polynomial.

    There are many academic articles describing rather arcane algorithms for recursive median lters. The rea- son I consider the algorithms arcane is they exclusively study nite impulse response (FIR) types of lters.

    This is because the applications being considered are being implemented in hardware rather than software. “Recursive” means using a previous calculation in the current calculation.

    APPLYING IT

    An example of a recursive lter used in trading is the exponential moving average (EMA). I propose a recur- sive median lter for trading be implemented as the EMA of a ve-bar median lter. A simple pseudocode representation of a recursive median lter is:

    Output = a*Median(Input, 5) + (1 – a)*Output[1];

    The EMA a is a constant between zero and 1. I prefer to calculate it in terms of the critical period of the lter. The critical period is where shorter wavelengths are passed by the lter and longer wavelengths are rejected at the lter output. The relationship between the EMA constant and critical period is expressed by the equation:

    a = (Cosine (360 / Period) + Sine (360 / Period) – 1) / Cosine (360 / Period)

    where the arguments of the trigonometric terms are in degrees.

    An easier-to-remember approximation to the re- lationship between the EMA constant and critical period is:

    a = 5 / Period

    MORE FILTERING

    An interesting and unique oscillator-type indicator can be cre- ated from the recursive median lter by further ltering with a second-order highpass lter. The highpass lter removes the DC (constant) values and very long wavelength components from the recursive median lter output. Using a second-order lter guarantees attenuation of the long wavelength components resulting from the statistical fractal pink-noise spectral shape of market data.

    The second-order nature of the highpass lter reduces its critical period about 70% relative to the critical period of an EMA lter. The EasyLanguage code to compute the recursive median oscillator is given in sidebar “EasyLanguage Code For Recursive Median Oscillator.”

    You can see the uniqueness and novelty of the recursive median oscillator when you compare it to the RSI (Figure 1). The recursive median oscillator is displayed in the rst sub- graph and the RSI is plotted in the second subgraph. The RSI is scaled to swing from -1 to +1 instead of the standard swing from zero to 100. The price data for Figure 1 is of the SPY for

    the calendar year 2017. The recursive median oscillator uses a 40-bar (two-month) critical highpass period and the RSI uses a standard 14-bar calculation. Both indicators have a smoothing lter critical period of 16 bars. From Figure 1 you can see that the recursive median oscillator has less lag and generally has faster response to the larger moves in the price data.

    SMOOTH AND EFFICIENT

    When data contains impulsive noise or uctuations in data, a trader needs to gure out how to smooth that data with the least amount of lag. The recursive median oscillator meets this need by ltering out outlier data, which gives a better view of the bigger picture.

    S&C Contributing Editor John Ehlers is a pioneer in the use of cycles and DSP technical analysis. He is president of MESA Software and cofounder of StockSpotter.com. MESASoftware. com offers the MESA Phasor and MESA intraday futures strategies.

    The code given in this article is available in the Article Code section of our website, http://www.Traders.com.

    (See our Traders’ Tips section beginning on page 48 for commentary and implementation of John Ehlers’ technique in various technical analysis programs. Accompanying program code can be found in the Traders’ Tips area at Traders.com.

    The EasyLanguage code to compute the recursive median Filter is given in sidebar “EasyLanguage Code For Recursive Median Filter.”)

  5. Bard • 03/08/2018 #

    Note: lter = filter

  6. Bard • 03/08/2018 #

    Apologies, there’s been an issue with copying “f” and “I” from the article and pasting.. which in part, is why I’m waiting for UPS to take this new MacBook Pro back to today…

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Appsoluxions Hi Nicolas, do you have the MT4 version of the indicator? I am not sure if these kind of que...
Nicolas Hi, don't have one sorry. But you can still ask for private coding through our programming s...
Appsoluxions Cool. Thanks for the response.
Etienne Hi, thanks for proving this code. I would like to contribute by adding a computation speed...
Etienne //Compute Super Smoother coefficients once if barindex = 1 then a1 = exp( -1.414 * 3.14159...
Nicolas Thanks a lot!
Nicolas
6 years ago
Nicolas Oui. Pour changer la période, il faudra ajuster la variable MMperiod
macbartin plus la période est grande (en occurrence 20) plus l'indicateur est précis dans les changeme...
Hasardeur Hallo Nicolas, in John Ehlers book "cycle analytics for Traders" from 2013, Mr. Ehlers desc...
Khaled Thanks, but if I may ask what's EMA Period? The price which reverses the EMA[20] is not the ...
Francesco78 EMA is not a moving average, it is just the name we called the quantity defined above
Khaled My bad. Thank you so much!
Gianluca Hello there is a new version, is it possible to translate it? https://www.tradingview.com...
christophe11560 bonjour, PRT me demande de réduire la période d'adaptive cyber Cycle suite à de fort ralent...
Pietro Fontana christophe11560, i've coded this a long time ago for a different version of the PRT, i'm not...
vitatrader35 Hola, Diego Puedes explicar cómo lo usas? Estoy tratando de emplearlo como validación de te...
diegofe_2000 Compra a la baja :  cruce de MEAN sobre AVG PEAK Compra al alza :   cruce de MEAN con AVG...
andrea ronca hi, do you know the best configuration for period, delta and fraction? thanks in advance
Etienne Hi, I'm quite late in this thread. I'd just like to propose an enhancement because this in...
Nicolas Thanks Etienne.
Bard Hi Nicolas, I wanted to make this scaled indicator above between -1 and +1 instead of 0 to +...
robertogozzi Vous ne pouvez pas, car ProBuilder ne prend actuellement pas en charge MTF (Multiple Time Fr...
jeanguy Merci pour ce travail En quoi cette MM est elle différente d’une MM courte ?
Bern latest version pro real time not accepting code, same with Ehler's MAMA indicator. any idea...

Top