*In statistics, the coefficient of determination, denoted R^{2} or r^{2} 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.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//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²" |

### Share this

**Risk disclosure:**

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

**ProRealTime ITF files and other attachments :**

**Filename :**download the ITF files

*How to import ITF files into ProRealTime platform?*

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials