Indicators: Linear Regression Channel

 

Linear Regression Channel:

The indicator plots a channel using the linear regression model: y=b+a*x.

When calculation of regression coefficients (a and b) it uses only completed bars. The number of bars should be greater than 2 (and less than total bars in history-1), it is specified in InChPeriod input parameter. The indicator values for the last (uncompleted) bar is calculated using the values of calculated regression coefficients.

The recalculation of the regression coefficient is performed when total bars in the history has changed, for example, for the case of a new bar.

Author: mvv444

LRChannel (Linear Regression Channel) indicator

 

Where can I find the IndicatorsAlgorithms.mqh file?
 
it autochanel! great!
 
Linear Regression Channel


Similar to the 200-day Moving Average, large institutions often look at long term Linear Regression Channels. A Linear Regression Channel consists of three parts:

  1. Linear Regression Line: A line that best fits all the data points of interest.
  2. Upper Channel Line: A line that runs parallel to the Linear Regression Line and is usually one to two standard deviations above the Linear Regression Line.
  3. Lower Channel Line: This line runs parallel to the Linear Regression Line and is usually one to two standard deviations below the Linear Regression Line.

The multi-year chart of the S&P 500 exchange traded fund (SPY) shows prices in a steady uptrend and maintaining in a tight one standard deviation Linear Regression Channel:


The upper and lower channel lines contain between themselves either 68% of all prices (if 1 standard deviation is used) or 95% of all prices (if 2 standard deviations are used). When prices break outside of the channels, either:

  1. Buy or sell opportunities are present.
  2. Or the prior trend could be ending.
Linear Regression Channel Buy Signal

When price falls below the lower channel line, a buy signal is usually triggered.

Linear Regression Channel Sell Signal

An opportunity for selling occurs when prices break above the upper channel line.

Other confirmation signs like prices closing back inside the linear regression channel could be used to initiate buy or sell orders. Also, other technical indicators should be used to confirm.

Trend Reversals

When price closes outside of the Linear Regression Channel for long periods of time, this is often interpreted as an early signal that the past price trend may be breaking and a significant reversal might be near.

Linear Regression Channels are quite useful technical analysis charting tools. In addition to identifying trends and trend direction, the use of standard deviation gives traders ideas as to when prices are becoming overbought or oversold relative to the long term trend.

 
IndicatorsAlgorithms.mqh file?
 
richeraraujo:
IndicatorsAlgorithms.mqh file?
It's not needed now. The code is updated (lrchannel.mq5).
 

Hi,

I've modified the code to add a parameter "Shift", this allows to calculate the channel in the past (Shift bars in the past, based on the last bar). This way one can quickly and optically verify strategies and / or entry points. 

Files:
Reason: