OPEN-SOURCE SCRIPT

Iteratively Reweighted Least Squares Range Filter [Jamallo]

1 383
Intro

Iteratively Reweighted Least Squares Range Filter


Most filters treat every bar equally. This one doesn't. The IRLS Range Filter uses a robust statistical engine to continuously evaluate how much each bar in the lookback window should be trusted — down-weighting noisy data and rejecting outliers entirely — before computing a consensus price level. The result is a smoother, more honest trend line that is far less susceptible to wicks, gaps, and volatile noise than conventional moving averages.

How It Works

The indicator runs in three stages:

Stage 1 — IRLS Consensus Engine. Every bar in the rolling window is assigned one of three trust states based on how far its price deviates from the current consensus, measured in adaptive sigma units. High Trust bars (within Lo-Trust Band σ) receive full weight. Lo Trust bars receive half weight. Rejected bars receive none. A Schmitt-trigger hysteresis mechanism prevents bars from flickering between states on minor fluctuations. The weighted average of all contributing bars becomes the consensus price. This residual-based weighting scheme is adapted from the IRLS framework described in Li & Deng (2026), arXiv:2603.08158.

Stage 2 — Deadband Quantizer. The continuous consensus is passed through a step filter. The output only moves when the consensus has shifted by more than one deadband unit (Step Size × σ). This eliminates micro-jitter and produces a clean staircase line with fewer false trend flips.

Stage 2.5 — Sample-and-Hold Bands. The volatility channel is only updated when the filter takes a new step, so band width reflects conditions at the last decisive move rather than real-time noise. An EMA-style smoother (Band Smooth) prevents abrupt band jumps between steps.

Reference

Li, J., & Deng, F. (2026). Outlier-robust Autocovariance Least Square Estimation via Iteratively Reweighted Least Square. arXiv preprint arXiv:2603.08158v1.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.