The “Linear regression slope” indicates the direction and intensity of the current trend.
In the abstract hypothesis of total absence of trend the slope of the linear regression is equal to zero: the linear regression is a line parallel to the abscissa axis.
A statistical way of establishing that there is no trend, and so we are in a laterality phase of the market, consists in establishing that the slope of our linear regression is statistically equal to zero in the observation period.
To do this in statistics we use the “t-test”.
For all those who love statistical problems I attach the pdf files with the related explanations.
The statistical formula is translated into the following code.
In a normal distribution, 95% of the data is included in a confidence interval of “Average + – 1.96”.
A “t-distribution” with infinitely many degrees of freedom is a normal distribution.
With an approximation we can state that if t <= 1.96 then our LinearRegressionSlope is equal to zero = there is no trend.
// period da ottimizzare
AA = period
t=(LinearRegressionSlope[AA](close)-0)*SQRT(AA-2)/(STE[AA](close)/STD[AA](Barindex))
if t<1.96 then
beta=0
else
beta=1
endif
return beta