OPEN-SOURCE SCRIPT

Linear Regression Log Channel with 3 Standard Deviations, Alerts

87
This indicator plots a logarithmic linear regression trendline starting from a user-defined date, along with ±1, ±2, and ±3 standard deviation bands. It is designed to help you visualize long-term price trends and statistically significant deviations.

Features:
• Log-scale linear regression line based on price since the selected start date
• Upper and lower bands at 1σ, 2σ, and 3σ, with the 3σ bands dashed for emphasis
• Optional filled channels between deviation bands
• Dynamic label showing:
• Distance from regression (in %)
• Distance in standard deviations (σ)
• Current price and regression value
• Estimated probability (assuming normal distribution) that the price continues moving further in its current direction
• Built-in alerts when price crosses the regression line or any of the deviation bands

This tool is useful for:
• Identifying mean-reversion setups or stretched trends
• Estimating likelihood of further directional movement
• Spotting statistically rare price conditions (e.g., >2σ or >3σ)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.