Correlation Coefficient

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts
  • #44759 quote
    Leonida1984
    Participant
    Average

    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

    #193231 quote
    Nicolas
    Keymaster
    Master

    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
Viewing 2 posts - 16 through 17 (of 17 total)
  • You must be logged in to reply to this topic.

Correlation Coefficient


ProBuilder: Indicators & Custom Tools

New Reply
Summary

This topic contains 16 replies,
has 1 voice, and was last updated by Nicolas
3 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/02/2016
Status: Active
Attachments: 2 files
Logo Logo
Loading...