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
Madrosat how do you use carnazzi filter in a strategy : smoothing , stop ,tendance
Bruno Carnazzi I have completely revised the mathematical foundations of this tool and offer you the finali...
Bruno Carnazzi Il me semble que la fonction "floor" n'est disponible qu'avec PRT11, à vérifier
DELBERT Bonjour , merci pour votre réponse , je m'excuse je suis avec PRT v10.3 donc c'est indicateu...
Nicolas c'est juste, c'est une instruction très récente.
RubberToe Is there something we are missing here, I just get the same curved line as well...
Khaled @Nicolas, Hi Nicolas, I've downloaded the itf and it doesn't display as an Oscillator, it"s ...
sal157011 I think the problem here is that you must feed the trigonometric functions cos and sin with ...
ggolfet Hi Actarus, what's the name of the histogram indicator below Apple's chart?
Actaru5 Flag ShowState in setting and show histogram
NicolaSilvagni hi, thank you for creating this indicator. i can't figure out how to get the three graphs b...
Nicolas Check your custom trading hours and use the default market ones.
fj_pastor Hello Nicolas, Thanks again for all your support. Finally I debugged the problem. The sim...
kallistos Hi Nicolas, Thank you very much indeed for this indicator (and all the others you are provi...
Morrissey38 Muchísimas gracias Nicolás , muy amable.
Bruno Carnazzi extrèmement pertinent
Bruno Carnazzi Is that beatable ?
Sapo Thank you for your indicators. As always it's perfect, I thank you for your help it's preci...
eivaremir have u got the trading view version?
carlvan That's a great indicator and I especially the use of colors, more or less pronounced to indi...
diegofe_2000 CORDIAL SALUDO. CUANDO REALIZO UN PROGRAMA CON ESTE INDICADOR ME SALE EL SIGUIENTE LETRE...
ALE Hello do you want to explain to me in more detail what you have to do? Please replay here:...
Nicolas Thanks again for all your valuable posts... and well formatted code! :)
Abdelkrim Maksour hi sir is this indicator for mt4 and how i can get one .
Nicolas Thanks a lot for this new valuable addition to our library. I changed line 76 with "barindex...
Horance Thanks. I've noticed this leftover after submission, but it was too late for editing. BTW, I...
Etienne Thanks Horance for porting this code to PRT. I would like to bring some speedup to your cod...
Horance This is a good question. John Ehlers explains it in Rocket Science for Traders. You have to ...
cbeukes Much appreciated, I will give that a try. Also, is there any criteria that one could use to ...
avatar
Anonymous Thanks for the code! I'm trying to understand how it works, and have a few questions... line...
Bebbo Grazie del prezioso contributo Nicolas, scusa la mia inesperienza, sono alle prime armi e s...
Nicolas To avoid recalculation, you should use the one from this post.
Bebbo Ok Grazie Nicolas.

Top