OPEN-SOURCE SCRIPT
Wx Linear / Log Regression Channel

Wx LinReg+ — Linear Regression Channel (with optional log scale)
LinReg+ is a modified version of TradingView’s built-in Linear Regression indicator.
In normal mode it behaves the same as the original script (same math, same channel) — but it adds a few extra tools for longer-term trend work and cleaner risk management.
⸻
What it does
• Plots a linear regression line over the last N bars (default 150) to show the dominant trend.
• Draws upper and lower channel lines at a chosen number of standard deviations from the regression line.
• Highlights when price moves unusually far away from its baseline, which can signal potential exhaustion or mean reversion.
• Optionally fits the channel on log(price) so the trend is percentage-based, which is much more realistic for long-term stocks, growth names, and crypto.
⸻
What’s different vs. the original Linear Regression
Everything from the standard TradingView Linear Regression is preserved, plus:
1. Use log price (percent-based)
• When checked, the regression is computed on log(source) instead of raw price.
• This makes the channel scale naturally with percentage moves (e.g., a move from 50 → 100 is treated like 100 → 200).
• Very useful on higher timeframes or multi-year trends.
2. Pearson’s R (trend quality)
• Optional label that shows Pearson’s correlation coefficient between price and the regression line.
• Values near +1 / −1 = strong, clean trend.
Values near 0 = choppy, noisy market.
3. Extend lines left / right
• Lets you project the channel back in time, forward in time, or both, without redrawing.
4. Default length
• Default Length = 150 bars to match a common swing / position-trading look-back out of the box.
⸻
Inputs
Channel Settings
• Length
Number of bars used for the regression calculation (default 150).
• Source
Price source used for the channel (close by default).
• Use log price (percent-based)
When enabled, regression is performed on log(price); visually still plotted on the normal scale.
• Upper Deviation / Lower Deviation
Number of standard deviations above/below the regression line to draw the upper and lower channel.
• Use Upper Deviation / Use Lower Deviation
Toggle visibility/use of each side of the channel.
Display Settings
• Show Pearson’s R
Shows a label with the correlation coefficient so you can quickly judge trend strength.
• Extend Lines Left / Extend Lines Right
Controls how far the channel lines are extended on the chart.
Color Settings
• Separate colors for upper band, lower band, and the filled areas between them.
⸻
How traders often use it
• Spot when price is stretched relative to its regression channel (possible fade / reversion zones).
• Confirm a trend regime: strong Pearson’s R + price riding the upper band = robust uptrend.
• On log mode, see whether a name is accelerating or decelerating in percentage terms over multi-month / multi-year windows.
This is a visual tool only – it doesn’t place orders or manage risk for you.
LinReg+ is a modified version of TradingView’s built-in Linear Regression indicator.
In normal mode it behaves the same as the original script (same math, same channel) — but it adds a few extra tools for longer-term trend work and cleaner risk management.
⸻
What it does
• Plots a linear regression line over the last N bars (default 150) to show the dominant trend.
• Draws upper and lower channel lines at a chosen number of standard deviations from the regression line.
• Highlights when price moves unusually far away from its baseline, which can signal potential exhaustion or mean reversion.
• Optionally fits the channel on log(price) so the trend is percentage-based, which is much more realistic for long-term stocks, growth names, and crypto.
⸻
What’s different vs. the original Linear Regression
Everything from the standard TradingView Linear Regression is preserved, plus:
1. Use log price (percent-based)
• When checked, the regression is computed on log(source) instead of raw price.
• This makes the channel scale naturally with percentage moves (e.g., a move from 50 → 100 is treated like 100 → 200).
• Very useful on higher timeframes or multi-year trends.
2. Pearson’s R (trend quality)
• Optional label that shows Pearson’s correlation coefficient between price and the regression line.
• Values near +1 / −1 = strong, clean trend.
Values near 0 = choppy, noisy market.
3. Extend lines left / right
• Lets you project the channel back in time, forward in time, or both, without redrawing.
4. Default length
• Default Length = 150 bars to match a common swing / position-trading look-back out of the box.
⸻
Inputs
Channel Settings
• Length
Number of bars used for the regression calculation (default 150).
• Source
Price source used for the channel (close by default).
• Use log price (percent-based)
When enabled, regression is performed on log(price); visually still plotted on the normal scale.
• Upper Deviation / Lower Deviation
Number of standard deviations above/below the regression line to draw the upper and lower channel.
• Use Upper Deviation / Use Lower Deviation
Toggle visibility/use of each side of the channel.
Display Settings
• Show Pearson’s R
Shows a label with the correlation coefficient so you can quickly judge trend strength.
• Extend Lines Left / Extend Lines Right
Controls how far the channel lines are extended on the chart.
Color Settings
• Separate colors for upper band, lower band, and the filled areas between them.
⸻
How traders often use it
• Spot when price is stretched relative to its regression channel (possible fade / reversion zones).
• Confirm a trend regime: strong Pearson’s R + price riding the upper band = robust uptrend.
• On log mode, see whether a name is accelerating or decelerating in percentage terms over multi-month / multi-year windows.
This is a visual tool only – it doesn’t place orders or manage risk for you.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
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.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
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.