Pearson Correlation Coefficient

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #166112 quote
    KhaledKhaled
    Participant
    Veteran

    In statistics, the Pearson correlation coefficient, also referred to as Pearson’s r, the Pearson product-moment correlation coefficient (PPMCC), is a measure of linear correlation between two sets of data. It is the covariance of two variables, divided by the product of their standard deviations; thus it is essentially a normalised measurement of the covariance, such that the result always has a value between −1 and 1.  https://en.wikipedia.org/wiki/Pearson_correlation_coefficient

    The Person’s  R is not to be confused with the R2 https://www.prorealcode.com/prorealtime-indicators/r-squared-correlation-coefficient-r2/ – Coefficient of determination – which measures the proportion of the variance in the dependent variable that is predictable from the independent variable(s). https://en.wikipedia.org/wiki/Coefficient_of_determination

    There was a discussion on this topic started here , but the initiator seem to have found the solution, but didn’t post it…

    So, I’ll try…

    //ρ (rho) = cov(x, y) / (sd(x) * sd(y)), where cov is covariance, sd(x) is the standard deviation of x, etc.
    
    // cov(x,y) = ((x - E(x) * (y - E(y) ), where E(x) is the Expected Value of x...
    
    // E(x) = average(x),  the expected value is the weighted sum of the xi values, with the probabilities pi as the weights. When values of x are equiprobable, then the weighted average turns into the simple average.
    
    // sd(x) = square root (variance(x;xn))
    
    // variance(x;xn) = (x-(average(x1;xn))^2 / n
    
    Period = 5
    IF barindex>Period THEN
    X         = close
    VarianceX = average[Period](SQUARE((X - average[Period](X))))
    sdX       = SQRT(VarianceX)
    
    Y         = RSI[14](close)
    VarianceY = average[Period](SQUARE((Y - average[Period](Y))))
    sdY       = SQRT(VarianceY)
    
    covXY     = average[Period]((X-average[Period](X)) * (Y-average[Period](Y)))
    
    R        = covXY / (sdX * sdY)
    
    ENDIF
    
    RETURN R

    While this correlation coefficient R shows the correlation between two variables for the current candle, I wonder if it’s not more appropriate to measure correlation of X (say Close) of candle [P] with another variable, say RSI, of previous candle [P-1]. Meaning that one can nealry predict at least direction of X based on the result of previous candle of Y.

    The most difficult now, is to find the most appropriate Y (RSI? Stoch? Volume? or combination of a few variables? calculated on same period than X or different period? )

    Please share your thoughts or any improvment you may think of.

    @Lars Nørgaard Larsen @Nicolas @Leonida1984  @Wing @robertogozziPLermite

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Pearson Correlation Coefficient


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Khaled @khaled Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/28/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...