Tools: Linear Regression Lines and Channel


A Linear Regression (LR) line is a trend line that is drawn mathematically so that is represents the 'best fit' for the data points it passes through.  The formulas use the least squares method to determine the line's placement.  This minimizes the distances between the data points and the trend line.

The algebraic expression for a straight line is:    y = b * x  + a     where  is the slope of the line and  is the y-intercept.   The linear regression formula calculate both the  b  and the  a  values.

This chart shows a linear regression trend line in its 'best fit' position.

One technique is to draw equally spaced channel lines at a distance based on Standard Deviation.  The Linear Regression draw tool in Ensign Windows has a multiplier parameter for the Standard Deviation offset.  The following example shows red channels lines drawn at 2 times the Standard Deviation.   Prices that stay outside of the regression channel indicate a change in trend.

 

The next technique that is based on Linear Regression trend lines, is to calculate a Linear Regression line for every set of  n  bars, and determine the price where the trend line intercepts the last bar in each data set.  Thus, one data point is determined for each bar in the chart, and these data points are then connected to create a Linear Regression curve, quite like a moving average.   The next chart illustrates several LR lines that each span a set of 5 bars.  The price where the LR line intercepts the last bar in each set of 5 bars is marked with a dot.  These intercept points are then connected by the red line to form a curve.

      

Click on the Study button to show the list of studies.  The study in Ensign Windows which is based on the above technique is called Regression Channel.  The center line is calculated as illustrated in the prior example.  Then bands are added whose distance from the regression center line is based on Standard Deviation.

The last technique discussed in this article is to plot the Slope of each Linear Regression trend line that is calculated for each set of  bars.   In our earlier example with several LR lines, each LR line has a slope.  Some have positive slopes wherein the lines are ascending.   Some have negative slopes wherein the lines are descending.  A change in the slope can be an early indication that the trend is changing direction.

This example shows the Regression Channel, with the Linear Regression Slope study plotted in green.

The Linear Regression Slope (LRS) is a plot of the  values calculated for each set of   n  bars.   In the last 3 illustrations,  n  had a value of 5.  This small set size makes for a choppy channel and a choppy LRS.  The lead article in this newsletter is a better example of how the LRS will look on a chart, and the set size parameter will be more useable when in the neighborhood of 10.

Ensign Windows users who would like to investigate the Linear Regression Slope study would select the Regression Channel from the study list, and check the Plot Slope (LRS) check box on the study property form.   The LRS will be plotted instead of the Regression Channel.   Upper and Lower bands may be added to the plot.

 


Last modified 8/11/08 12:10 PM