Clarification on Correlation
Author: sedelstein
Creation Date: 9/4/2013 2:40 PM
profile picture

sedelstein

#1
I need a clarification on the WL Correlation method
http://www2.wealth-lab.com/WL5Wiki/CorrelationSeries.ashx

If I understand correctly, I could pass Closing prices to this method and it would calculate the correlation based on the levels of those prices.

If I wanted to calculate the correlation of say, daily returns, I would first need to calculate the daily rate of changes and then pass it to the correlation method.

Thanks, the reason for asking is that in general finance literature correlations are generally assumed to be the correlation of returns. I don't think this method is doing that



One other question, is there a code snippet out there that would show for a dataset, how to generate all pairwise correlations among the symbols. I've looked at the pairs code, and it seems that you can run all symbols against a single external symbol.
profile picture

Eugene

#2
QUOTE:
If I wanted to calculate the correlation of say, daily returns, I would first need to calculate the daily rate of changes and then pass it to the correlation method.

That's right.

QUOTE:
One other question, is there a code snippet out there that would show for a dataset, how to generate all pairwise correlations among the symbols.

Correlation Matrix strategy by Sammy_G is exactly what you're looking for.
profile picture

sedelstein

#3
Thanks for the fast response
profile picture

kbellare

#4
I'm trying to get correlation of 1day ROC with common indicators such as RSI, etc (code below).
I was expecting to see a X-Y correlation graph that ranges from a 45-degree line (perfect correlation) to a blob (no correlation).

1) How do i generate such a graph?

2) Also, I got a flat-line for the 2 charts drawn by the code - not sure how to interpret it.


CODE:
Please log in to see this code.


profile picture

Eugene

#5
The chosen period (2000) is too high so no wonder it turns into a flat line.

Caution: do not use CorrelationXL as it may produce out of memory exception or even crash. In upcoming update of the extension, it will be replaced with Correlation internally.
profile picture

kbellare

#6
I tried with 400 bars but it still shows 0 for both graphs (attached screenshot).

Note in my code i'm shifting forward the price dataseries in order to correlate today's indicator value to next day's price movement, to assess it's predictive power. If that's causing the issue, please suggest how i modify the code to get this correlation graph/function.

thanks
Kiran

profile picture

Eugene

#7
You did not understand me. Of course with 400 bars loaded and period = 2000 the lines are going to be flat. Change the Period, not the data loading range.

On how to modify your code code to adjust your objectives, please count me out. Here's the source code if you want to dig deeper:

Home - Community Indicators