Linear Regression is a statistical tool used to predict future values from past values. By using the least squares method, a straight line can be plotted that minimizes the distance between the resulting line and the data set in order to reveal a trend.
The Linear Regression Indicator (LRI) plots the end value of a Linear Regression Line at each data point. A variation on the same idea is the Time Series forecast (TSF) which is found by adding the Linear Regression Slope to the Linear Regression Line. The TSF basically projects the LRI forward one period. The TSF is also sometimes referred to as a Moving Linear Regression or Regression Oscillator.
By calculating these two indicators on a moving basis the result looks similar to that of a moving average and can be used in the same way.
.
Calculating a Linear Regression Line
.
Linear Regression Line = a + bx
Where:
a = (Σy – bΣx) / n
b = (nΣ(xy) – (Σx) (Σy)) / (nΣx² – (Σx)²)
b = Linear Regression Slope.
x = The current time period.
y = The data series (Usually the close price).
n = Number of periods.
.
Linear Regression Indicator & Time Series Forecast Excel File
.
Calculating these indicators by hand is a pain in the ass so we have build an Excel spreadsheet containing both the Linear Regression Indicator and Time Series forecast that you can download for free. Find it at the following link near the bottom of the page under Downloads – Technical Indicators: Linear Regression Indicator (LRI) & Time Series Forecast (TSF). Please let us know if you find it useful.
.
Linear Regression Indicator, Time Series Forecast and a Simple Moving Average
.
.
Test Results
.
We tested the Linear Regression Indicator and Time Series forecast through 300 years of data across 16 global markets to reveal which is the best and if either of them are worth using as trading tool for data smoothing – see the results.
.
.