I essentially need to calculate the exponential linear regression slope (based on lognormal prices), then annualize it based on 250 trading days in a year, and then multiply it by RSquared. I have drafted the following code, but not sure if correct.
Any help would be seriously & highly appreciated!!!!
Code: Select all
// Annualized Exponential Linear Regression Slope
Inputs:
Price (Close),
Length1 (250);
Vars:
LRS1 (0), AnnExpLRS1 (0), T1(0);
LRS1 = LinearRegSlope(Log(Price), Length1);
AnnExpLRS1 = (power((1+LRS1),250) - 1) * 100;
T1= AnnExpLRS1 * RSquare(Barnumber, Price, Length1);
Plot1(T1, "T1");
Plot2( 5, "5Line" ) ;
Plot3( 0, "ZeroLine" ) ;