OPEN-SOURCE SCRIPT

TASC 2025.07 Laguerre Filters

524
█ OVERVIEW

This script implements the Laguerre filter and oscillator described by John F. Ehlers in the article "A Tool For Trend Trading, Laguerre Filters" from the July 2025 edition of TASC's Traders' Tips. The new Laguerre filter utilizes the UltimateSmoother filter in place of an exponential moving average (EMA) in its calculation, offering improved responsiveness and reduced lag.


█ CONCEPTS

As Ehlers explains in his article, the Laguerre filter is a form of transversal filter. A transversal filter calculates an output signal using a tapped delay line. It creates multiple delayed versions of an input signal, applies weight to each delay, and then calculates their sum to generate the filtered result.

The Laguerre filter's structure relies on Laguerre polynomials — solutions to a differential equation solved by Edmond Laguerre in the 1800s. When Ehlers analyzed the formula for these polynomials on discrete systems (e.g., financial time series), he found that the first term's expression corresponds to an EMA response, and all subsequent terms correspond to an all-pass response. In contrast to other filter types, an all-pass filter produces phase shift (i.e., delay) in an input signal's components without affecting its amplitude.

Ehlers observed that these characteristics of Laguerre polynomials make them suitable for use in a transversal filter structure, and thus the Laguerre filter was born. However, he notes that EMAs are not great filters in general. As such, to improve on the Laguerre filter's design, Ehlers modified it by replacing the EMA term with his UltimateSmoother filter. The resulting Laguerre filter has significantly reduced lag, achieving a tighter response to market fluctuations while maintaining smoothness. Ehlers suggests that traders can analyze crossings between the UltimateSmoother and this Laguerre filter, or those between two Laguerre filters of different order, for helpful buy and sell signals.

In addition to the Laguerre filter, Ehlers derived a smooth, low-lag oscillator based on the difference between the first and second terms in the modified filter structure, scaled by the root mean square (RMS). The resulting oscillator provides an alternative filtered representation of market data, which can help traders identify swing and mean-reversion signals.


█ USAGE

This indicator calculates both the Laguerre filter and the Laguerre oscillator described in Ehlers' article. It displays the Laguerre filter on the main chart pane and the oscillator in a separate pane.

Users can control the behavior of the filter and oscillator with the inputs in the "Settings/Inputs" tab:
  • The "Period" input defines the critical period of the UltimateSmoother used in the Laguerre filter and oscillator calculations. Its default value is 30.
  • The "Gamma" input determines the weighting behavior of the Laguerre filter and oscillator. It accepts a positive value between 0 and 1. Use a lower value for quicker responsiveness to market changes, and a higher value for trends. The default value is 0.5.
  • The "RMS length" input determines the length of the RMS calculation for oscillator normalization. The default value is 100 bars.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.