How to calculate the Slope of the Linear Regression Curve?  [SOLVED]

Questions about MultiCharts and user contributed studies.
jimpe606
Posts: 6
Joined: 19 Aug 2013

How to calculate the Slope of the Linear Regression Curve?

Postby jimpe606 » 20 Aug 2013

Hi,

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" ) ;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to calculate the Slope of the Linear Regression Curv

Postby TJ » 22 Aug 2013

Try the function LinearRegvalue.

jimpe606
Posts: 6
Joined: 19 Aug 2013

Re: How to calculate the Slope of the Linear Regression Curv  [SOLVED]

Postby jimpe606 » 24 Aug 2013

Hi,

After a discission with MC support I understand the function actually works but I had to decrease the length from what initially tried, i.e. the legth of the curve indikator and slope function would in my case be different. E.g. 40 length of indikator may use 9 in length of slope. To be tuned...

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: How to calculate the Slope of the Linear Regression Curv

Postby TJ » 24 Aug 2013

Hi,
After a discission with MC support I understand the function actually works but I had to decrease the length from what initially tried, i.e. the legth of the curve indikator and slope function would in my case be different. E.g. 40 length of indikator may use 9 in length of slope. To be tuned...
Thanks for the update.

Rodger
Posts: 1
Joined: 27 Feb 2016

Re: How to calculate the Slope of the Linear Regression Curve?

Postby Rodger » 20 Feb 2017

what's the difference between your result with linear regression slope?


Return to “MultiCharts”