The Linear Regression Indicator plots the trend of a market instrument’s price over a specified length of time. The trend is determined by calculating a Linear Regression Trendline using the “least squares fit” method. This method helps to minimum distance between the data points and a Linear Regression Trendline. Unlike the straight Linear Regression Trendline, the Linear Regression indicator plots the ending values of multiple Linear Regression trendlines. Any point along the Linear Regression Indicator will be equal to the ending value of a Linear Regression Trendline, but the result looks like a moving average. However, unlike a moving average, the Linear Regression Indicator does not exhibit as much delay since it is fitting a line to data points rather than averaging them.
Many trading strategies assume that the way a stock moves during a specific time of day can be used to predict the way a stock will move later in the day. How would you verify or automate such a strategy? Start by recording historical values. Each day, record the size and direction of the change in the first period, and the direction and size of the second change, later in the day. One point on a graph will represent each day’s data. If the original idea was correct, these points should look like a line. If this is the case, a trader can look at the size of a move in the morning, and guess what the second move that day will look like.
Linear regression provides a deterministic way to this. First, linear regression will provide an R-Squared value for the historical data. If this value is too small, the data is not linear, so the original assumptions must change. If R-Squared is large enough, then the linear regression will provide the best prediction of the second move each day based on the first move.
Interpretation
The Linear Regression Indicator is actually a forecast of the tomorrow’s price plotted today. When prices are persistently higher or lower than the forecasted price, expect them to quickly return to more realistic levels. In other words, the Linear Regression Indicator shows where prices “should” be trading on a statistical basis and any excessive deviation from the regression line is likely to be short-lived.
Implementation
The Regression Periods, Price, Pre-Smoothing Price Periods and Pre-Smoothing MA Type inputs have been parameterized to allow the user full customization of this indicator. The resulting regression indicator is displayed as a bi-color indicator. A rising regression line (greater than its previous value 1 bar ago) is displayed in the UpLine color, while a declining regression line (lower than its previous value 1 bar ago) is displayed in the DownLine color.