In statistics, the coefficient of determination, denoted R2 or r2 and pronounced “R squared”, is the proportion of the variance in the dependent variable that is predictable from the independent variable(s) (wikipedia).
The R-squared indicator gives a correlation coefficient between 0 to 1 (0 = no correlation , 1 = highly correlated) by comparing the injected data to a straight linear regression line.
This indicator gives the same values as the R2 instruction. Some asked me the code to study the embedded instruction of the platform, here it is.
//PRC_R-Squared coefficient | indicator
//19.09.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
period = 20
// --- end of settings
Data = customclose
SumX = 0
SumXX = 0
SumXY = 0
SumYY = 0
SumY = 0
if barindex>Period then
for k=0 to period-1 do
tprice = Data[k]
SumX = SumX+(k+1)
SumXX = SumXX+((k+1)*(k+1))
SumXY = SumXY+((k+1)*tprice)
SumYY = SumYY+(tprice*tprice)
SumY = SumY+tprice
next
Q1 = SumXY - SumX*SumY/period
Q2 = SumXX - SumX*SumX/period
Q3 = SumYY - SumY*SumY/period
iRsq=((Q1*Q1)/(Q2*Q3))
endif
return iRsq as "R²"