OPEN-SOURCE SCRIPT

Linear Regression Trend Channel

Updated
The "Linear Regression Trend Channel" is a technical indicator designed to illustrate price trends and their volatility using linear regression. This indicator calculates the main linear regression line based on the user-defined period length and computes the standard deviation to form a trend channel.

Key Features:

- Linear Regression Calculation: Computes the linear regression line based on the selected price data source and the defined period length.
- Slope and Intercept Calculation: Calculates the slope and intercept of the linear regression line using the calcSlopeIntercept function.
- Deviation Channels: Adds standard deviation channels to the linear regression line to highlight potential support and resistance areas.

Settings

- Linear Regression Length: Specifies the length of the period for the linear regression calculation (default: 100).
- Linear Regression Source: Defines the data source for the linear regression calculation, such as close price, open price, etc. (default: close).
- Linear Regression Color: Sets the color of the linear regression line (default: gray).
- Show Price Labels: Option to display price labels on the horizontal lines (default: true).

How to Use

- Set the Linear Regression Length to define the period for regression calculation.
- Choose the Linear Regression Source to specify the price data (e.g., close, open).
- Enable or disable Show Price Labels based on whether you want to see price labels on the horizontal lines.

This Indicator helps identify dynamic support and resistance levels and potential market turning points.
Release Notes
The "Linear Regression Trend Channel" is a technical indicator designed to illustrate price trends and their volatility using linear regression. This indicator calculates the main linear regression line based on the user-defined period length and computes the standard deviation to form a trend channel.

Key Features:

- Linear Regression Calculation: Computes the linear regression line based on the selected price data source and the defined period length.
- Slope and Intercept Calculation: Calculates the slope and intercept of the linear regression line using the calcSlopeIntercept function.
- Deviation Channels: Adds standard deviation channels to the linear regression line to highlight potential support and resistance areas.

Settings

- Linear Regression Length: Specifies the length of the period for the linear regression calculation (default: 100).
- Linear Regression Source: Defines the data source for the linear regression calculation, such as close price, open price, etc. (default: close).
- Linear Regression Color: Sets the color of the linear regression line (default: gray).
- Show Price Labels: Option to display price labels on the horizontal lines (default: true).

How to Use

- Set the Linear Regression Length to define the period for regression calculation.
- Choose the Linear Regression Source to specify the price data (e.g., close, open).
- Enable or disable Show Price Labels based on whether you want to see price labels on the horizontal lines.

Add Customization:

- Linear Regression Color: Sets the color of the linear regression line.
- Label Price Color: Sets the color of the displayed price labels.
- Show Price: Option to display or hide the price labels.
- Show Horizontal Line: Option to display or hide horizontal lines.

This Indicator helps identify dynamic support and resistance levels and potential market turning points.
Release Notes
Add Customization:

- Linear Regression Color: Sets the color of the linear regression line.
- Label Price Color: Sets the color of the displayed price labels.
- Show Horizontal Line: Option to display or hide horizontal lines.
- Show Price: Option to display or hide the price labels.
Release Notes
Updates:
High/Low Timeframe Addition:

The High/Low lines mark the highest and lowest prices over a chosen timeframe (e.g., daily, weekly). These levels often act as support and resistance.

- Added an input parameter to select the timeframe (e.g., daily, weekly) for displaying High and Low levels.
- Added an input to choose the color of the High/Low lines.
- Added an option to show or hide the High/Low lines on the chart.

The High/Low lines make it easier to see key price points on the chart, set price targets, and identify trends, improving readability.
Release Notes
- Added Timeframe Options: Expanded the available timeframes for high/low calculations to include daily, weekly, monthly, 3-month, 6-month, and yearly intervals.
- Extended High/Low Lines: Enhanced the high/low lines to extend both forward and backward, providing a clearer historical and future reference.
- General Improvements: Minor code optimizations for better performance and accuracy.
jeetbeezLinear RegressionTrend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer