Linear Regression Forecast



Linear regression is a common statistical technique used to forecast values using the least squares fit method. This technique is applied in technical analysis to determine if the market trending up or down and what should the price be, given the recent trend of prices. In other words, the Linear Regression Forecast is a prediction of future prices charted in the present based on past quotes.

The Linear regression technique is used for calculating the anticipated value of one variable when one has the values of independent variable or variables M. This is in the form of a straight line which “best fits” the data points of prices available. In technical analysis, the Linear Regression line shows the principal market trend with respect to time. It is used to analyse when the market is deviating from the trend. The Linear Regression Forecast is drawn by calculating the regression based on a certain fixed regression time period (X). This is used to draw the regression line at each bar or time period based on the previous (X-1) time periods and optionally forecasting it for Y future time periods. The Linear Regression Forecast line thus drawn illustrates where prices "should" be trading. Any abnormal divergence from the regression line is likely to be temporary or it may signal that a major trend reversal is taking place. However, this is useful as an indicator only when markets are not highly volatile and prices do not swing prodigiously around the trend. The less volatile the market, the better the fit of the equation is to the data, and therefore the more dependable is the linear trend.


The trend is determined by calculating a Linear Regression Trend Line using the "least squares fit" statistical method at each bar. The least squares method helps in plotting a straight line that minimizes the distance between the resulting line and the data points (in this case the prices) in order to reveal a trend. The linear regression forecast is an intense calculation process as it involves calculation of regression lines at each bar. The prices used for calculating the regression can optionally be smoothed using a moving average calculation. If the prices are not smoothed, then the actual price can be used. In addition, a forecast for a certain period can also be calculated and used. The endpoint of the line thus drawn is used at the value for that bar. This is calculated as follows:

Regression = Reg(Price, X) + Slope * Y


X=regression period,
Y=Forecast period,
Slope=Slope of the regression line (which indicates the strength of the trend through gradient)

Usually this is overlaid by also drawing the Upper and Lower bands. These are calculated by computing the number of standard deviations above or below the regression line. The calculation used for calculating the Upper and the Lower bands is as follows:

Upper Regression Band = Regression + StdDev (Price, X) * N
Lower Regression Band = Regression – StdDev (Price, X) * N


N=number of standard deviations,
X=regression period

Calculating the Linear Regression Forecast on a moving basis makes the result looks similar to Moving Average and can be used as a substitute for the Moving Average. However, the Linear Regression Indicator does not show as much delay as Moving Average as it is fitting a line to data points instead of averaging them.



The Linear Regression Forecast can be customized by optionally smoothing the price data using a moving average for price based on a specified number of time periods. In addition, a forecast of a specified number of time periods can also be calculated with the endpoint of the line being used for the value for that bar. Typically the Linear Regression Forecast is presented as a channel with the regression value in the middle and an upper band and lower band drawn suing specified number of standard deviations from the regression value.

Lengths and timeframes

Linear Regression Forecast is typically used for short term trend identification and confirmation or optionally for spotting trend reversals. It can be used for intra-day or daily or weekly trend identification. It sometimes proves useful as an alternative to moving average. It should not be used for longer term or cyclical forecasts. 

Trend identification / Crossovers

This is used to show the overall trend line. It can also show the support and resistance levels using the upper and lower bands of the channel. The upper and lower channel lines contain 68% of all historical price moves at 1 standard deviation, and 95% at 2 standard deviations.

When prices break outside the channels, either:
1. Buy or sell opportunities are present (buy below lower trend, sell above upper trend).
2. Or the major trend could be ending.

This means that any movement beyond 2 standard deviations show an unlikely movement (less than 5% probability) and indicates that security is overbought or oversold and would tend to bounce back. The trend should be confirmed with other technical indicators and signs, such as prices closing back inside the linear regression channel to take positional buy or sell orders.

When the price stubbornly remains closed outside the Linear Regression Channel for extended duration, this is often an advance signal of the earlier price trend ending and an important reversal is happening.


This study is for identifying trends and the trend direction. In addition the standard deviation overlay provides traders an indication when positions are overbought or oversold relative to the long term trend. The LRF can be used as a substitute for moving average. However, there is no delay or lag in the LRF as it uses best fitting from data rather than average. Also, this is more responsive to price changes.


This indicator should not be used when prices fluctuate widely around the trend line. The fit of the trend to the data is most likely not very reliable.