Good afertoon everyone, could someone help me?
I need to use code of The Pearson R Correlation whitout the problem that I wrote above.
Thanks
For future reference, the pinescript instruction “correlation” is the same as this prorealtime code:
ProBuilder" >//correlation(x, y, len)
len = 20
x = barindex
y = customclose
lenMinusOne = len - 1
meanx = 0.0
meany = 0.0
for i=0 to lenMinusOne
meanx = meanx + (x[i])
meany = meany + (y[i])
next
meanx = meanx / len
meany = meany / len
sumxy=0.0
sumx=0.0
sumy=0.0
for i=0 to lenMinusOne
sumxy = sumxy + ((x[i]) - meanx) * ((y[i]) - meany)
sumx = sumx + pow((x[i]) - meanx, 2)
sumy = sumy + pow((y[i]) - meany, 2)
correlation = sumxy / sqrt(sumy * sumx)
next
return correlation