How to Find Correlation Coefficient of any Stocks in 2 seconds using Wealth Lab - Trade Algo

How to Find Correlation Coefficient of any Stocks in 2 seconds using Wealth Lab

July 31, 2017

In the following video I explain in detail the code for Wealth Lab which will get the correlation coefficient for you. It works on any timeframe and any symbol within the Wealth Lab infrastructure. The formula was invented by an English man from Islington in London Karl Pearson during his life in 1857 – 1936 and goes like this:

correlation coef formula

We take two lists of values and find r which is the correlation coefficient. The big scary letter means the sum of. So for each set of values, for each value which is on the list we fisrt find the required function and then we add the values up. For example we find the multiple of x*y first and then add up the values. Same with the square roots.

The close the value is to 1 or -1 the more correlated the two stocks are. The only difference is the direction of correlation. For example if they are positivly correlated it means if one moves up the other one will move up as well. It means the opposite for negatively correlated stocks ie. if one goes up the other one will go down. For example the price of Brent Oil goes down and the price of a USD/RUB future will go up because you will have to pay more rubles to buy 1000 dollars which is the size of one contract.

The code for the correlation coeficient find method you can download HERE

That’s great but it is static. We take all data for two securities for let’s say 1-2 years and we get the coef but how do we peak in inside, wonder what’s going on with the correlation between two stocks during any time period. Check out the next video on the dynamic correlation coefficient indicator for Wealth Lab.

Here is the link for the CODE