Linear Regression Line & Moving Linear Regression
A Linear Regression line can be applied to price or another indicator. Linear Regression lines are drawn backward from the most recent bar. The length of the line is the period specified. (On a Daily chart, a period of 50 would mean that the Linear Regression line is 50 days long.)
Linear Regression fits the best average line between any two points, thereby showing the trend clearly and accurately.
You can combine short and long periods to see the overall and short term trends.
A Moving Linear Regression line plots the path of the endpoint of a linear regression line back through the chart. The example below shows a 1000 period Linear Regression and a 30 period Moving Linear Regression. You'll notice that the end of the Moving Regression (cyan) coincides with the endpoint of the Regression line (yellow). The Moving Linear Regression doesn't actually display the regression line itself, but in the graphic examples here it's displayed for illustrative purposes.
Of Price | Moving / Right End Point |
3 * FAVGCx.z - 2 * AVGCx.z |
x =Period, z =Offset |
Slope |
6 * (FAVGCx.z - AVGCx.z) / (x - 1) |
||
Left End Point |
4 * AVGCx.z - 3 * FAVGCx.z |
||
Mid Point |
AVGCx.z |
||
Generalized | Moving / Right End Point |
3 * FAVG(w, x) - 2 * AVG(w, x) |
w =Numeric, x =Period |
Slope |
6 * (FAVG(w, x) - AVG(w, x)) / (x - 1) |
||
Left End Point |
4 * AVG(w, x) - 3 * FAVG(w, x) |
||
Mid Point |
AVG(w, x) |
Where x
is the Period and must be an integer.
Where z
is the offset. An offset of 1 returns the value from 1 bar ago.
Where w
is any formula returning a numeric value. Any offsets would need to be included as part of the syntax for that numeric formula.
Examples
A 30 period moving linear regression of price can written as follows.
3 * FAVGC30.0 - 2 * AVGC30.0
But you don't need the offset parameters since it is for the current bar.
3 * FAVGC30 - 2 * AVGC30
This is format as the value of the right endpoint of a linear regression line of the same period since that is what is being plotted by the moving linear regression.
Read more about Linear Regression analysis at Investopedia