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
Slope=Slope of the regression line (which indicates the strength of the trend through
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,
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.