Need help to get the slope/angle of a linear regression curve?
I explored the function LinearReg and tried to plot the slope and the angle, but don't get what I expected (couldn't find any documentation that explain it). I compare the value curve withe linear regression curve plotted by the indicator "Linear Reg Curve" with same period length and data input.
Expected
If the regression curve is flat, I expected the value to be near 0, if curve pointing up get a positive value and if the curve is pointing down a negative value.
I plotted a regression curve of a intraday chart and observered several locations where the curve is flat, but then the slope or angle seems to have random values.
Definition:
http://en.wikipedia.org/wiki/Slope
Code used to plot:
Code: Select all
inputs:
Price( Close ),
Length( 40 ),
Displace( 0 ) ;
variables:
value1( 0 ), var0( 0 ), var1( 0 ), var2( 0 ), var3( 0 ) ;
value1 = LinearReg( Price, Length, 0, var0, var1, var2, var3 ) ;
Plot1[Displace]( var0, "LinRegSlope" ) ;
//plot2[Displace](var1, "LinRegAngle" ) ;