OPEN-SOURCE SCRIPT
Linear Regression Channel With Pearson's R (Multi Sigma & MTF)

This indicator applies multi‑sigma linear regression across multiple institutional time horizons to quantify the line of best fit in equities and index markets. By combining multi‑timeframe presets with statistically derived deviation bands, it highlights trend structure, volatility expansion, and regime transitions with clarity.
What’s New in This Update
The original version of the indicator produced a linear regression channel with multiple deviation bands. However, the statistical values it displayed were not mathematically valid. The value labeled “r” was not Pearson’s correlation coefficient and could not be used to derive R² or any formal regression diagnostics.
This update introduces a fully correct statistical engine based on ordinary least squares (OLS).
NEW STATISTICAL OUTPUTS
These values are mathematically valid, bounded, and directly tied to the regression line.
KEY IMPROVEMENTS
• Correct OLS intercept (removes the erroneous +slope term)
• Proper predicted values using ŷ = b₀ + b₁x
• Correct centering around the actual mean of the data
• Removal of correlation logic from the deviation engine
• Clean separation between statistical computation and volatility computation
• Regression channel visuals remain identical, but the underlying math is now fully accurate
These changes ensure that r and R² reflect true trend strength and model fit, enabling more reliable interpretation of long‑term and short‑term trend regimes.
CORE FEATURES (UNCHANGED)
More information can be found here:
https://github.com/HeyItsSamir/Linear-Regression-Channel-Multi-Sigma-Auto-MTF
What’s New in This Update
The original version of the indicator produced a linear regression channel with multiple deviation bands. However, the statistical values it displayed were not mathematically valid. The value labeled “r” was not Pearson’s correlation coefficient and could not be used to derive R² or any formal regression diagnostics.
This update introduces a fully correct statistical engine based on ordinary least squares (OLS).
NEW STATISTICAL OUTPUTS
• True Pearson’s r
• True R² (coefficient of determination)
• RSS (Residual Sum of Squares)
• TSS (Total Sum of Squares)
These values are mathematically valid, bounded, and directly tied to the regression line.
KEY IMPROVEMENTS
• Correct OLS intercept (removes the erroneous +slope term)
• Proper predicted values using ŷ = b₀ + b₁x
• Correct centering around the actual mean of the data
• Removal of correlation logic from the deviation engine
• Clean separation between statistical computation and volatility computation
• Regression channel visuals remain identical, but the underlying math is now fully accurate
These changes ensure that r and R² reflect true trend strength and model fit, enabling more reliable interpretation of long‑term and short‑term trend regimes.
CORE FEATURES (UNCHANGED)
• Auto‑Multi‑Timeframe presets aligned with institutional trend horizons
• Multi‑Sigma bands (+/‑1σ, +/‑2σ, +/‑3σ) for volatility structure and statistical extremes
• True least‑squares regression recalculated each bar
• Deviation mode toggle (Standard Deviation vs. Max Deviation)
• Full documentation and institutional use‑case examples available on GitHub
More information can be found here:
https://github.com/HeyItsSamir/Linear-Regression-Channel-Multi-Sigma-Auto-MTF
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.