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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
No courses, don't sell signals — just my own edge, stats public: jalgo.ca/
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
No courses, don't sell signals — just my own edge, stats public: jalgo.ca/
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。