Hello. How to calculate the slope in degrees of a linear regression? What am I doing wrong?
Plot( C, "Price", colorDefault,styleBar|styleThick );
period = 5;
Plot( LinearReg( C, period ), "LinearReg", colorBlue );
bi = BarIndex();
sbi = SelectedValue( bi );
b = SelectedValue( LinRegIntercept( C, period ) );
a = SelectedValue( LinRegSlope( C, period ) );
x = bi - sbi;
ll = a * ( x + period - 1 ) + b;
ll = IIf( x >= - period AND x <= 0, ll, Null );
Plot( ll, "Line", colorRed, styleThick );
bb = LinRegSlope(C, period );
pi = 4 * atan(1);
slopeangle = atan( bb)*( 180 / pi );
printf("Slope");
WriteVal(slopeangle);