Updated
[blackcat] L2 Ehlers Laguerre Filter

Level: 2
Background
John F. Ehlers introuced Laguerre Filter in his "Cybernetic Analysis for Stocks and Futures" chapter 14 on 2004.
Function
The Laguerre transform can be represented as an exponential moving average (EMA) low-pass filter (the first term) followed by a succession of allpass elements instead of unit delays (the k − 1 terms). All terms have exactly the same damping factor γ (gamma). We see that these are all pass networks by examining the frequency response. Dr. Ehlers made a filter using the Laguerre elements instead of the unit delay, whose coefficients are also [1 2 2 1]/6 as with the FIR filter. The difference is that we have warped the time between the delay line
taps.
Key Signal
FIR ---> Laguerre Filter fast line
Filt ---> Laguerre Filter slow line
Pros and Cons
100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.
Remarks
The 33th script for Blackcat1402 John F. Ehlers Week publication.
Readme
In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.
The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.
Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.
Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.
Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.
Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.
Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
Background
John F. Ehlers introuced Laguerre Filter in his "Cybernetic Analysis for Stocks and Futures" chapter 14 on 2004.
Function
The Laguerre transform can be represented as an exponential moving average (EMA) low-pass filter (the first term) followed by a succession of allpass elements instead of unit delays (the k − 1 terms). All terms have exactly the same damping factor γ (gamma). We see that these are all pass networks by examining the frequency response. Dr. Ehlers made a filter using the Laguerre elements instead of the unit delay, whose coefficients are also [1 2 2 1]/6 as with the FIR filter. The difference is that we have warped the time between the delay line
taps.
Key Signal
FIR ---> Laguerre Filter fast line
Filt ---> Laguerre Filter slow line
Pros and Cons
100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.
Remarks
The 33th script for Blackcat1402 John F. Ehlers Week publication.
Readme
In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.
The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.
Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.
Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.
Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.
Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.
Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
Release Notes
OVERVIEW his script implements the Ehlers Laguerre Filter, a technical analysis tool that generates filtered and FIR signals for market trend analysis. It includes divergence detection features for both bullish and bearish patterns.
FEATURES
• Two primary signals:
Filtered Signal (Filt): Purple line
FIR Signal (FIR): Yellow line • Divergence detection with customizable parameters:
Regular Bullish/Bearish
Hidden Bullish/Bearish • Alert conditions for all divergence types • Customizable lookback periods and range settings
HOW TO USE
Adjust the input parameters:
• Price: Select the price source (default: hl2)
• Gamma: Set the filter sensitivity (default: 0.8)
• Lookback periods (Left/Right)
• Range limits (Upper/Lower)
• Toggle visibility of different divergence types
Interpret the signals:
• Watch for crossovers between Filt and FIR lines
• Monitor divergence labels for potential trading opportunities
• Use alerts to notify of new divergence formations
LIMITATIONS
• Requires sufficient historical data for accurate calculations
• Performance may vary depending on market conditions
• Parameter optimization needed for specific trading pairs
NOTES
• The script uses Ehlers' Laguerre transformation for signal filtering
• Divergence detection is based on price and oscillator relationships
• Alert conditions are provided for all divergence types
Release Notes
█ OVERVIEWThis open-source overlay applies John Ehlers' Laguerre Filter to your chart and turns its FIR/Filt crossovers into a complete governed trading system with entries, exits, ATR-based take-profit and stop-loss reference levels, divergence detection, and full alert coverage.
█ CONCEPTS
The Laguerre Filter is a four-stage adaptive smoother that reacts quickly while suppressing noise. The script plots the smoothed line (Filt, fuchsia) against a 4-bar FIR reference (FIR, yellow) and reads their crossovers:
• Filter crossover: FIR crossing the Laguerre line marks momentum shifts
• Signal governance: a position state machine, same-bar exit priority, and a configurable cooldown suppress whipsaw in ranges
• Risk levels: entry-anchored, volatility-adaptive stop-loss and take-profit lines from ATR multiples
• Divergence engine: regular and hidden bullish/bearish divergence between price pivots and the FIR oscillator
█ HOW TO USE
1 — Add the indicator; defaults work out of the box (Price = hl2, Gamma = 0.8)
2 — Tune Gamma: lower values react faster, higher values smooth more
3 — Read signals: green BUY / red SELL labels mark governed entries, orange XL/XS crosses mark exits
4 — Use the ATR-based Stop Loss and Take Profit lines as per-trade reference levels
5 — Create alerts from the alert dropdown; choose "Once Per Bar Close" for confirmed signals
Input Parameters
• Filter: Price source (hl2), Gamma damping factor 0.0 to 0.999 (default 0.8)
• Governance: state machine on/off, exit-priority exclusivity, Cooldown Bars (3, 0 = off)
• Risk: ATR Length (14), Stop Loss 2.0 xATR, Take Profit 3.0 xATR, show/hide levels
• Divergence: Pivot Lookback 5/5, Lookback Range 5 to 60, four per-type toggles (hidden types off)
• Visual: Signal Labels, Position Background, Dashboard Table
█ FEATURES
• Governed entry and exit signals with a consistent label system and position background
• ATR-based stop-loss and take-profit levels anchored to each entry
• Four divergence types with pivot lines, labels, and dedicated alerts
• On-chart dashboard: position state, ATR, TP/SL levels, cooldown remaining
• Eight alert conditions: long/short entry, long/short exit, four divergences
• Label budget managed; every threshold exposed as an input
█ SIGNALS
Visual Elements
• Green BUY below the bar: FIR crossed above the Laguerre line (long entry)
• Red SELL above the bar: FIR crossed below the Laguerre line (short entry)
• Orange XL / XS cross: long / short exit
• Fill between FIR and Filt: which line currently dominates
• Green / red background tint: current governed position state
• Bull / Bear labels with thick pivot lines: regular divergence
• H Bull / H Bear labels: hidden divergence (off by default)
█ IMPLEMENTATION NOTES
Open source, Pine Script v6, no request.security calls — no higher-timeframe repaint sources. Signals evaluate on bar close; on the realtime bar a label may appear or disappear until the bar closes, so use "Once Per Bar Close" alerts. The Laguerre recursion preserves the original published algorithm; governance, risk, and visual layers are additive and independently switchable.
█ LIMITATIONS
• Crossover systems fire frequently in ranges; governance and cooldown reduce but do not eliminate whipsaw
• TP/SL lines are reference levels, not automated orders — this is an indicator, not a strategy
• Divergence confirms its right-side lookback bars after the actual pivot, by design
• Best in trending conditions; test on your symbol and timeframe first
█ NOTES
• Filter based on John F. Ehlers' Laguerre Filter (Cybernetic Analysis for Stocks and Futures)
• Divergence section adapted from TradingView's built-in Divergence Indicator approach
• Part of the blackcat open-source Pine series — attribution appreciated
════════════════════════════════════════════════════════════════════════
For questions or feedback, please use the comments section below.
Feel free to use and modify — attribution appreciated.
Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq My new github for more pine development soon: github.com/wxt-coder
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.
Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq My new github for more pine development soon: github.com/wxt-coder
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.