OPEN-SOURCE SCRIPT

IIR One-Pole Price Filter [BackQuant]

784
IIR One-Pole Price Filter [BackQuant]
A lightweight, mathematically grounded smoothing filter derived from signal processing theory, designed to denoise price data while maintaining minimal lag. It provides a refined alternative to the classic Exponential Moving Average (EMA) by directly controlling the filter’s responsiveness through three interchangeable alpha modes: EMA-Length, Half-Life, and Cutoff-Period.

Concept overview
An IIR (Infinite Impulse Response) filter is a type of recursive filter that blends current and past input values to produce a smooth, continuous output. The "one-pole" version is its simplest form, consisting of a single recursive feedback loop that exponentially decays older price information. This makes it both memory-efficient and responsive, ideal for traders seeking a precise balance between noise reduction and reaction speed.
Unlike standard moving averages, the IIR filter can be tuned in physically meaningful terms (such as half-life or cutoff frequency) rather than just arbitrary periods. This allows the trader to think about responsiveness in the same way an engineer or physicist would interpret signal smoothing.

Why use it
  • Filters out market noise without introducing heavy lag like higher-order smoothers.
  • Adapts to various trading speeds and time horizons by changing how alpha (responsiveness) is parameterized.
  • Provides consistent and mathematically interpretable control of smoothing, suitable for both discretionary and algorithmic systems.
  • Can serve as the core component in adaptive strategies, volatility normalization, or trend extraction pipelines.


Alpha Modes Explained
  • EMA-Length: Classic exponential decay with alpha = 2 / (L + 1). Equivalent to a standard EMA but exposed directly for fine control.
  • Half-Life: Defines the number of bars it takes for the influence of a price input to decay by half. More intuitive for time-domain analysis.
  • Cutoff-Period: Inspired by analog filter theory, defines the cutoff frequency (in bars) beyond which price oscillations are heavily attenuated. Lower periods = faster response.


Formula in plain terms
Each bar updates as:
yₜ = yₜ₋₁ + alpha × (priceₜ − yₜ₋₁)
Where alpha is the smoothing coefficient derived from your chosen mode.
Smaller alpha → smoother but slower response.
Larger alpha → faster but noisier response.

Practical application
  • Trend detection: When the filter line rises, momentum is positive; when it falls, momentum is negative.
  • Signal timing: Use the crossover of the filter vs its previous value (or price) as an entry/exit condition.
  • Noise suppression: Apply on volatile assets or lower timeframes to remove flicker from raw price data.
  • Foundation for advanced filters: The one-pole IIR serves as a building block for multi-pole cascades, adaptive smoothers, and spectral filters.


Customization options
  • Alpha Scale: Multiplies the final alpha to fine-tune aggressiveness without changing the mode’s core math.
  • Color Painting: Candles can be painted green/red by trend direction for visual clarity.
  • Line Width & Transparency: Adjust the visual intensity to integrate cleanly with your charting style.


Interpretation tips
  • A smooth yet reactive line implies optimal tuning — minimal delay with reduced false flips.
  • A sluggish line suggests alpha is too small (increase responsiveness).
  • A noisy, twitchy line means alpha is too large (increase smoothing).
  • Half-life tuning often feels more natural for aligning filter speed with price cycles or bar duration.


Summary
The IIR One-Pole Price Filter is a signal smoother that merges simplicity with mathematical rigor. Whether you’re filtering for entry signals, generating trend overlays, or constructing larger multi-stage systems, this filter delivers stability, clarity, and precision control over noise versus lag, an essential tool for any quantitative or systematic trading approach.

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.