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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
//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" |

### 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 :**

**Filename :**download the ITF files

*How to import ITF files into ProRealTime platform?*

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

Yantra• 03/17/2021 #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.

Gregory• 03/17/2021 #Hello Nicolas, I have the same problem as Yantra, do you have any suggestion to fix it? Thank you

LUCASSEN• 03/17/2021 #The same problem

DonTony• 03/17/2021 #Bonjour Nicolas,

J’ai le même problème. L’oscillateur ne s’affiche pas correctement.

Une solution?

pableitor• 03/17/2021 #the code works just fine, just note the parameters in the source code are different than the picture’s.

RubberToe• 03/17/2021 #Doesn’t work for me, the .ift or the code above…

Bruno Carnazzi• 03/17/2021 #Il y a à boire et à manger chez Ehlers, quand même 🙂

RubberToe• 03/17/2021 #Is there something we are missing here, I just get the same curved line as well…

Khaled• 355 days 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

sal157011• 355 days 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