A Linear Regression line is a line of best fit among a contiguous selection of stock prices. It is a statistical way of drawing a trend line and uses the least squares mathematical formula. Once the best fit line has been drawn it is possible to determine the standard deviation of the stock price from the line. Standard deviation channels can then be drawn equidistant from the linear regression line. A 2 standard deviation channel will contain 95% of all the stock prices and a 1 standard deviation channel will contain 68% of all prices.

Here’s an example of a 252 day linear regression line with a 2 standard deviation channel:

## Period of the Linear Regression Line

The one parameter you need to draw a linear regression line is the period of the line. The period indicates how many bars should be taken into account when calculating the line using the least squares method. The fewest number of bars you need to calculate a linear regression line is two, in which case the line will start at the first close and end at the second close. There is no maximum number of bars. Longer lines indicate longer term trends and shorter lines indicate shorter term trends. A 252 day line equates to a one-year trend as there are approximately that number of trading days in one year.

Here’s the same chart as above but with a 21 day linear regression line shown:

## Slope of the Linear Regression Line

An interesting property of the line is the Slope which is the rise-over-run of the line. For instance if the 20 day linear regression line starts at a value of 100 and ends at a value of 110 the slope of the line is:

(110 – 100)/20 = 0.5

The value of the slope indicates line direction and steepness, however it is not so useful for comparing the trend strength of different stocks due to being based on price rather than percentage. For instance, compare the value of slope for a 20 day line which starts at 1000 and ends at 1010:

(1010 – 1000)/20 = 0.5

It has the exact same slope value but the percentage increase is much lower.

A more useful way to compare slopes among different stocks is to use a percentage value. EdgeRater has developed a value which is a forecast % of a 1 year period, meaning that if the line continued on for another year at the current slope rate it would be X% higher than it is today (or X% lower for negative slopes).

In the above charts you can see 2 indicators in the lower area:

LRPctAnnSlope: This is the forecast annualized % increase or decrease in the line end value

LRPctAnnSlopeChg: This is the change in annualized slope value from the previous day.

## Linear Regression Curve

The linear regression line is redrawn every day which changes its slope and also changes the standard deviation channel width. It is useful to plot the end value of the line and channels for each prior day and also view the slope value and slope change for each prior day.

The following chart shows the Linear Regression Curve. The Linear Regression Line for one of the bars has been super-imposed to show where it was at that time. You can see that the end value of the line sits right on the curve:

## Analyzing Linear Regression Channels with EdgeRater

The EdgeRater template ‘Linear Regression Channel Analysis’ can be used to produce an Excel report showing Linear Regression Channel values for each stock in your symbol list. You can navigate through this report while viewing it in EdgeRater to see updated charts.

Here’s a video that explains more:
{"ft_lang_label":"__label__en","ft_lang_prob":0.9087333,"math_prob":0.95305556,"size":3463,"snap":"2020-34-2020-40","text_gpt3_token_len":744,"char_repetition_ratio":0.1630529,"word_repetition_ratio":0.016207455,"special_character_ratio":0.2142651,"punctuation_ratio":0.057228915,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99892974,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-09-19T05:53:42Z\",\"WARC-Record-ID\":\"<urn:uuid:8d84d09a-49ff-4565-89c5-a6453946e424>\",\"Content-Length\":\"44136\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:53c65dd1-3517-430f-ae64-2a6fadb14d66>\",\"WARC-Concurrent-To\":\"<urn:uuid:3cbbb11e-58a4-4ebd-a7f7-2c35ee66694c>\",\"WARC-IP-Address\":\"34.83.223.147\",\"WARC-Target-URI\":\"https://blog.edgerater.com/linear-regression-channel-analysis-for-stocks/\",\"WARC-Payload-Digest\":\"sha1:7BTHLBT3UK6SSS4TDDVVBJ7SCD4HXNKJ\",\"WARC-Block-Digest\":\"sha1:CNFBDWPI2YJUP7MINI66SOI7JDZFWFAO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-40/CC-MAIN-2020-40_segments_1600400190270.10_warc_CC-MAIN-20200919044311-20200919074311-00046.warc.gz\"}"}