Untitled
"TASC 2025.07 Laguerre Filters" by PineCodersTASC, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: TASC 2025.07 Laguerre Filters (v1.0), read 2026-11-15T18:30:31.413Z; source language v6.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
TASC 2025.07 Laguerre Filters by PineCodersTASC, ported from Pine v6. Pane indicator with 2 plots, 1 level and 4 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2025-06-15; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// TASC Issue: July 2025
// Article: A Tool For Trend Trading
// Laguerre Filters
// Article By: John F. Ehlers
// Language: Pine-compatible v6
// Provided By: PineCoders, for tradingview.com
// ------------------------------------------------------------------------------------------------
// Original author: PineCodersTASC
// Original title: TASC 2025.07 Laguerre Filters
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 6
// Fetched: 2026-11-15
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=6
TITLE = "TASC 2025.07 Laguerre Filters"
SHORT_TITLE = "LF"
indicator(TITLE, SHORT_TITLE)
//#region --- Inputs ---
// @variable The source series.
float sourceInput = input.source(close, "Source:")
// @variable The critical period of the UltimateSmoother.
const string TT1 = "Critical period of the UltimateSmoother."
int usInput = input.int(30, "Period:", 3, tooltip=TT1)
// @variable The "gamma" value for Laguerre calculations.
const string TT2 = "Use a lower value for quicker responsiveness to market movements, and a higher value for trends."
float gammaInput = input.float(0.5, "Gamma:", 0.0, 0.999, 0.01, tooltip=TT2)
// @variable The number of bars in the RMS calculation.
const string TT3 = "Length of the RMS for oscillator normalization."
int rmsInput = input.int(100, "RMS length:", 1, tooltip=TT3)
//#endregion
//#region --- Functions ---
// @function Calculates the UltimateSmoother filter.
// The UltimateSmoother's response is the
// result of subtracting the response of
// a highpass filter from that of an allpass
// filter.
// See [TASC 2024.04](https://www.tradingview.com/script/X67OSwqc-TASC-2024-04-The-Ultimate-Smoother/)
// @param src The source series to process.
// @param period The length of the filter's critical period.
// @returns The smoothed series.
ultimateSmoother(float src, int period) =>
float a1 = math.exp(-1.414 * math.pi / period)
float c2 = 2.0 * a1 * math.cos(1.414 * math.pi / period)
float c3 = -a1 * a1
float c1 = (1.0 + c2 - c3) / 4.0
float us = src
if bar_index >= 4
us := (1.0 - c1) * src + (2.0 * c1 - c2) * src[1] - (c1 + c3) * src[2] + c2 * nz(us[1]) + c3 * nz(us[2])
us
// @function Calculates a modified Laguerre filter based
// on the UltimateSmoother.
// @param src The source series to process.
// @param period The critical period of the UltimateSmoother
// used as the first term in the Laguerre
// polynomial.
// @param gamma Optional. Controls the phase response of
// the filter's terms. With a smaller gamma,
// the filter is more responsive to rapid
// changes. With a larger gamma, the filter
// is more responsive to trends. The default is 0.8.
// @returns The filtered series.
laguerreFilter(float src, int period, float gamma = 0.8) =>
float l0 = ultimateSmoother(src, period)
float l1 = 0.0
float l2 = 0.0
float l3 = 0.0
float l4 = 0.0
float l5 = 0.0
float g1 = 1.0 - gamma
l1 := g1 * nz(l0[1], src) + gamma * nz(l1[1], src)
l2 := g1 * nz(l1[1], src) + gamma * nz(l2[1], src)
l3 := g1 * nz(l2[1], src) + gamma * nz(l3[1], src)
l4 := g1 * nz(l3[1], src) + gamma * nz(l4[1], src)
l5 := g1 * nz(l4[1], src) + gamma * nz(l5[1], src)
float lf = nz(l0 + 4.0 * l1 + 6.0 * l2 + 4.0 * l3 + l5) / 16
// @function Calculates the root mean square (RMS) of a series.
// @param source The series of values to process.
// @param length The number of bars in the calculation.
// @returns The RMS of the `source` values over `length` bars.
rms(float source, int length) =>
math.sqrt(ta.sma(source * source, length))
// @function Calculates the Laguerre oscillator, representing
// the normalized difference between zeroth- and
// first-order terms from a modified Laguerre
// filter based on the UltimateSmoother.
// @param src The source series to process.
// @param period The critical period of the UltimateSmoother.
// @param gamma Optional. Controls the phase response of
// the filter's terms. With a smaller gamma,
// the filter is more responsive to rapid
// changes. With a larger gamma, the filter
// is more responsive to trends. The default is 0.5.
// @param rmsLen Optional. The length of the RMS calculation that
// normalizes the oscillator. The default is 100.
// @returns The Laguerre oscillator.
laguerreOscillator(float src, int period, float gamma = 0.5, int rmsLen = 100) =>
float l0 = ultimateSmoother(src, period)
float l1 = 0.0
l1 := nz(l0[1], src) + gamma * (nz(l1[1], src) - l0)
float diff = l0 - l1
float rms = rms(diff, rmsLen)
float lOsc = rms != 0.0 ? diff / rms : rms
//#endregion
//#region --- Calculations and display ---
// @variable The Laguerre filter of the `src` series with specified settings.
float filter = laguerreFilter(sourceInput, usInput, gammaInput)
// @variable The Laguerre oscillator for the `src` series with specified settings.
float oscillator = laguerreOscillator(sourceInput, usInput, gammaInput, rmsInput)
// Plot the `filter` series on the main chart pane.
plot(filter, "Laguerre Filter", linewidth=2, force_overlay=true)
// Display the `oscillator` series and a zero line in a separate pane.
plot(oscillator, "Laguerre Oscillator", #f23645, 2)
hline(0, "Zero line", chart.fg_color)
//#endregion
This file is under the Mozilla Public License 2.0; it is a port of the original by PineCodersTASC, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.