Ehlers Simple Decycler

Category: Indicators By: Nicolas Created: April 8, 2020, 9:18 AM
April 8, 2020, 9:18 AM
Indicators
16 Comments

This indicator was originally developed by John F. Ehlers (Stocks & Commodities , V.33:10 (September, 2015): “Decyclers”).

Mr. Ehlers suggested a way to improve trend identification using high-pass filters. The basic smoothers like SMA , low-pass filters, have considerable lag in their display. Mr. Ehlers applied the high-pass filter and subtracted the high-pass filter output from the time series input. Doing these steps he removed high-frequency short-wavelength components (the ones causing the wiggles) from the time series.

As a result he got a special series of the low-frequency components with virtually no lag – the Decycler.

The Decycler is plotted with two additional lines (the percent-shifts of Decycler) and together they form a hysteresis band.

If the prices are above the upper hysteresis line, then the market is in an uptrend. If the prices are below the low hysteresis line, then the market is in a downtrend. Prices within the hysteresis band are trend-neutral.

(description found on the web, indicator converted from Pinescript language following multiple requests on the forums).

//PRC_Ehlers Simple Decycler | indicator
//08.04.2020
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
highpassLength = 20
upperPercent = 0.5 //Upper Band % Shift
lowerPercent = 0.5 //Lower Band % Shift
highlightMovements = 1 //Highlight Decycler Movements ? 0=false ; 1=true
// --- end of settings 

src = close

once PI = 3.14159265359

if barindex>highpassLength then 
 // High-pass Filter
 alphaArg = 2 * PI / (highpassLength * sqrt(2))

 alpha = 0.0

 if cos(alphaArg) <> 0 then 
  alpha = (cos(alphaArg) + sin(alphaArg) - 1) / cos(alphaArg)
 else
  alpha = alpha[1]
 endif

 hp = 0.0
 hp = square(1 - (alpha / 2)) * (src - 2 * src[1] + src[2]) + 2 * (1 - alpha) * hp[1] - square(1 - alpha) * hp[2]

 decycler = src - hp

 if highlightMovements then 
  if decycler >= decycler[1] then 
   r=0
   g=255
  else
   r=255
   g=0
  endif
 endif

 upperBand = (1 + upperPercent / 100) * decycler
 lowerBand = (1 - lowerPercent / 100) * decycler
endif

return decycler coloured(r,g,0) style(line,2) as "Decycler", upperband coloured(19,132,132) as "upper band", lowerband coloured(19,132,132) as "lower band"

 

Download
Filename: PRC_Ehlers-Simple-Decycler.itf
Downloads: 544
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...