Recursive Median Oscillator by John Ehlers

Category: Indicators By: Despair Created: March 8, 2018, 11:40 AM
March 8, 2018, 11:40 AM
Indicators
6 Comments

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.

LPPeriod=12
HPPeriod=30
length=5
once Median=0
if barindex>length then
 // Set EMA constant from LPPeriod input
 Alpha1 = ( Cos( 360 / LPPeriod )+ Sin( 360 / LPPeriod ) - 1 )/ Cos( 360 / LPPeriod )

 // get the median of the last length (default=5) closes

 FOR X = 0 TO length-1
  M = close[X]    //this example takes the median of the last 5 closes
  SmallPart = 0
  LargePart = 0
  FOR Y = 0 TO length-1
   IF close[Y] < M THEN
    SmallPart = SmallPart + 1
   ELSIF close[Y] > M THEN
    LargePart = LargePart + 1
   ENDIF
   IF LargePart = SmallPart AND Y = length-1 THEN
    Median = M
    BREAK
   ENDIF
  NEXT
 NEXT

 // Recursive Median (EMA of a 5
 // bar Median filter)

 RM = Alpha1 * Median + ( 1 - Alpha1 ) * RM[1]

 // Highpass filter cyclic components
 // whose periods are shorter than
 // HPPeriod to make an oscillator

 Alpha2 = ( Cos( .707 * 360 / HPPeriod ) + Sin( .707 * 360 / HPPeriod ) - 1 ) / Cos( .707 * 360 / HPPeriod )

 RMO = ( 1 - Alpha2 / 2 ) * ( 1 - Alpha2 / 2 ) * ( RM - 2 * RM[1] + RM[2] ) + 2 * ( 1 - Alpha2 ) * RMO[1] - ( 1 - Alpha2 ) * ( 1 - Alpha2 ) * RMO[2]
endif

return RMO as "RMO", 0 as "0"

 

Download
Filename: Ehlers-Recursive-Median-Oscil..itf
Downloads: 172
Download
Filename: bildschirmfoto-um-1520503045c8p4l.png
Downloads: 44
Despair Master
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

Logo Logo
Loading...