Nicolas

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
John F. Ehlers Decycler Oscillator

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: 275
Nicolas
Nicolas Legend
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

sal157011
5 years ago
#

I think the problem here is that you must feed the trigonometric functions cos and sin with degrees and not with radians. In the code where is 2*pi should be 360. See 2015/09/TradersTips

Khaled
5 years ago
#

@Nicolas, Hi Nicolas, I've downloaded the itf and it doesn't display as an Oscillator, it"s more like a two parralel curves. I tried to zoom in and out, same. I tried various combinations of Slow/Fast Periods and Ks, same problem. Any chance you can look into it please? Thanks

RubberToe
5 years ago
#

Is there something we are missing here, I just get the same curved line as well...

Bruno Carnazzi
5 years ago
#

Il y a à boire et à manger chez Ehlers, quand même :)

pableitor
5 years ago
#

the code works just fine, just note the parameters in the source code are different than the picture's.

RubberToe
5 years ago
#

Doesn't work for me, the .ift or the code above...

DonTony
5 years ago
#

Bonjour Nicolas, J'ai le même problème. L'oscillateur ne s'affiche pas correctement. Une solution?

LUCASSEN
5 years ago
#

The same problem

Gregory
5 years ago
#

Hello Nicolas, I have the same problem as Yantra, do you have any suggestion to fix it? Thank you

Yantra
6 years ago
#

The Oscillator is not displaying correctly on my system, it's not oscillating it's just a long gentle curve diagonally across the window. I have tried it both with the default settings and the 10, 15 you have on the screenshot above. I'm on Prorealtime v11.1 with IG. Any clues why this is occurring? Thank you.

ProRealCode ProRealCode
Loading...