Ehlers DecyclerJohn F. Ehlers introuced Decycler in his book "Cycle Analytics for Traders", chapter 4.
The decycler is designed to remove the influence of shorter cycle fluctuations, resulting in an output that closely resembles a one-pole low-pass filter.
A standout feature of the decycler is its notably minimal lag. The most extended cycle elements experience a delay of less than five bars. When considering a frequency of 0.05 cycles per bar (equivalent to a 20-bar cycle period), the lag approximates 1.5 bars. Components with a higher frequency face even lesser delays. Consequently, any higher-frequency variations that pass the filter's attenuation align closely with the price fluctuations. This makes the decycler an optimal "immediate trend detector," giving a true depiction of the data's trend.
While the SuperSmoother filter can yield a comparably smoothed output, the decycler typically exhibits less lag when the two are juxtaposed. It's worth noting that the decycler operates as a one-pole filter, implying it doesn't have the best filtering capabilities. It's not advisable to use the decycler as a smoothing filter to eliminate aliasing disturbances. Instead, its application should focus on generating an immediate trend representation, especially when choosing a larger cutoff period. The broad cutoff period equips the decycler with the ability to reduce aliasing disturbances, given that it's significantly distant from the Nyquist frequency.
There are already several decycler indicators on Tradingview, but I like to structure the code and highlight the main components as functions rather than hiding them in the code. I hope this is useful for those who are starting to learn Pine Script.
Decycle
Ehlers Decycler Oscillator [CC]The Decycler Oscillator was created by John Ehlers (Cycle Analytics For Traders pgs 43-44) and it is used to show transitions between uptrends and downtrends. If it rises above the 0 line then this means it has transitioned to an uptrend and it falls below the 0 line then it is in a downtrend. Buy if the indicator line is green and sell when it is red.
This was a custom request so let me know if you would like to see more scripts from me or if you want something custom done!
Ehlers Decycler [CC]The Decycler was created by John Ehlers (Cycle Analytics For Traders pgs 40-41) and this is a moving average that has an extremely low lag even though it uses a fairly high length to calculate everything. This can also work well as a trendline. Buy when the indicator line is green and sell when it is red.
Let me know if there are other scripts you would like to see me publish or if you want something custom done!
Ehlers Decycler OscillatorThis indicator was originally developed by John F. Ehlers (Stocks & Commodities , V.33:10 (September, 2015): "Decyclers").
The idea is still the same as for the Simple Decycler.
Mr. Ehlers suggested to virtually eliminate lag by getting rid of the very low-frequency components. So, he applied the high-pass filter to the simple decycler.
Mr. Ehlers recommended to use two instances of the Decycler Oscillator with different parameters (high-pass filter period and multiplier). As a result, he got the Decycler Oscillator pair.
The first oscillator (red line) has a period of 125 bars, the second one (yellow line) has a period of 100 bars.
The interpretation is straightforward:
When the yellow line crosses over the red line, a trend reversal to the upside is indicated.
When the yellow line crosses under the red line, a trend reversal to the downside is indicated.
Ehlers Simple DecyclerThis 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 .