Linear regression analyzes the relationship between two variables, X and Y. For each subject (or experimental unit), you know both X and Y and you want to find the best straight line through the data. In some situations, the slope and/or intercept have a scientific meaning. In other cases, you use the linear regression line as a standard curve to find new values of X from Y, or Y from X.
In most instances when it comes to trading it is best to keep things as simple as possible. It is possible to write intricate formulas for analyzing and back-testing data with linear regressions. Through personal experience it seems best to focus on the time frame or the length of the linear regression and the overall slope of the regression line. Below is a chart of the S&P 500 with a longer term linear regression line. This regression line is shown as the red straight line that bisects the prices over the past 377 days. On either side of this red line are lines which show one standard deviation (blue lines) and two standard deviations (yellow lines). These lines run parallel to the linear regressions and act as channels.
S&P 500 Index
This is a longer term view of the market, but it does help in showing when the market is at mathematical extremes. It can help in knowing when not to fight a trend and when to expect support to possibly help adding to a position. It is important to note that the entire slope of the linear regression is positive. Creating long positions when the market is 2 standard deviations above this line could prove to be positive, but looking for better entries on pull-backs to the regression line or to the one standard deviation line could be significantly safer.
The chart below further smooths the data by using a three day chart. This is a custom time frame that is longer than a daily chart, but is shorter than a weekly chart. When using the 3day chart, most of the data will stay within one standard deviation of our linear regression line.
S&P 500 Index 3 Day Chart
Looking back to the late 90's, it is possible to see how the market reacted to these levels as the trend changed. This chart below is a three daily chart with the same linear regression line.
S&P 500 Index 1997-2002