OPEN-SOURCE SCRIPT
Iteratively Reweighted Least Squares Range Filter [Jamallo]

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.
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.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
No courses, don't sell signals — just my own edge, stats public: jalgo.ca/
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
No courses, don't sell signals — just my own edge, stats public: jalgo.ca/
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.