John F. Ehlers Decycler Oscillator

Category: Indicators By: Nicolas Created: March 17, 2021, 12:56 PM
March 17, 2021, 12:56 PM
Indicators
10 Comments

In “Decyclers” in Sep, 2015, John Ehlers described a method for constructing an oscillator that could help traders detect trend reversals with almost no lag, an oscillator that signals trend reversals with almost zero lag via digital signal processing techniques. A high-pass filter is subtracted from the input data and the high-frequency components are removed via cancellation of terms. Lower-frequency components are filtered from the output, so they are not canceled from the original data. Thus, the decycler displays them with close to zero lag. The fast line has a period of 100 a K value of 1.2 and the slow line has a period of 125 and a K value of 1.

This indicator demonstrates the timely response of the decycler oscillator to market action. It applies the idea of using a decycler oscillator pair with different parameters, as discussed in Ehlers’ article:
1. Enter long when the fast line crosses over the slow line;
2. Exit long when the fast line crosses under the slow line.

//PRC_Ehlers Decycler Oscillator | indicator
//17.03.2021
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
FastHPPeriod = 100 //Fast_HPPeriod
SlowHPPeriod = 125 //Slow_HPPeriod
FastK = 1.2 //Fast_K
SlowK = 1.2 //Slow_K
// --- end of settings 

Price = medianprice

once pi = 3.14159265359

if barindex>max(fasthpperiod,slowhpperiod) then 
 //fast
 alpha1 = ( cos ( 0.707 * 2 * pi / FastHPPeriod ) + sin( 0.707 * 2 * pi / FastHPPeriod ) - 1 ) / cos( .707 * 2 * pi / FastHPPeriod )
 HP = ( 1 - alpha1 / 2 ) * ( 1 - alpha1 / 2 ) * ( Price - 2 * Price[1] + Price[2] ) + 2 * ( 1 - alpha1 ) * HP[1] - ( 1 - alpha1 ) * ( 1 - alpha1 ) * HP[2]
 Decycle = Price - HP
 alpha2 = ( cos( 0.707 * 2 * pi / ( 0.5 * FastHPPeriod ) ) + sin( 0.707 * 2 * pi / ( 0.5 * FastHPPeriod ) ) - 1) / cos( 0.707 * 2 * pi / ( 0.5 * FastHPPeriod ) )
 DecycleOsc = ( 1 - alpha2 / 2 ) * ( 1 - alpha2 / 2 ) *  ( Decycle - 2 * Decycle[1] + Decycle[2] ) + 2 *  ( 1 - alpha2 ) * DecycleOsc[1] - ( 1 - alpha2 ) * ( 1 - alpha2 ) * DecycleOsc[2]
 DecyclerOscillatorF = 100 * FastK * DecycleOsc / Price
 //slow
 salpha1 = ( cos ( 0.707 * 2 * pi / SlowHPPeriod ) + sin( 0.707 * 2 * pi / SlowHPPeriod ) - 1 ) / cos( .707 * 2 * pi / SlowHPPeriod )
 sHP = ( 1 - salpha1 / 2 ) * ( 1 - salpha1 / 2 ) * ( Price - 2 * Price[1] + Price[2] ) + 2 * ( 1 - salpha1 ) * (sHP[1]) - ( 1 - salpha1 ) * ( 1 - salpha1 ) * (sHP[2])
 sDecycle = Price - sHP
 salpha2 = ( cos( 0.707 * 2 * pi / ( 0.5 * SlowHPPeriod ) ) + sin( 0.707 * 2 * pi / ( 0.5 * SlowHPPeriod ) ) - 1) / cos( 0.707 * 2 * pi / ( 0.5 * SlowHPPeriod ) )
 sDecycleOsc = ( 1 - salpha2 / 2 ) * ( 1 - salpha2 / 2 ) *  ( sDecycle - 2 * (sDecycle[1]) + (sDecycle[2]) ) + 2 *  ( 1 - salpha2 ) * (sDecycleOsc[1]) - ( 1 - salpha2 ) * ( 1 - salpha2 ) * (sDecycleOsc[2])
 DecyclerOscillatorS = 100 * SlowK * sDecycleOsc / Price
endif

return DecyclerOscillatorF coloured(200,200,0) as "Fast Val", DecyclerOscillatorS coloured(200,0,200) as "Slow Val"

 

Download
Filename: PRC_Ehlers-Decycler-Oscillator.itf
Downloads: 271
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...