For those who may be thinking about including correlation in the logic of their trading systems, I've attached five test cases to help you debug your code. Each test case is a pair of "instruments" (it might be a pair of stocks, or a pair of futures, or forex, or spreadbets, or CFDs, or ETFs; it really doesn't matter). Each instrument is a price data file, containing about 1.5 years' worth of end-of-day prices, in the standard
- Open, High, Low, Close, Volume, OpenInterest, UnadjustedClose
The price files contain Open + High + Low + Close but to reduce clutter, I've only plotted the Close prices in the charts below. You'll see "EX1A.c" in the legend; that is simply the close price of instrument EX1A.
Put these pairs into your software that calculates correlation. TELL IT TO ANALYZE AT LEAST 100 BARS (days) WORTH OF DATA. These test cases contain patterns that are 100 bars long and you need to get the entire pattern into your correlation calculation. Probably the simplest thing to do is to tell your software to analyze the final 200 bars of data. 200 is an easy-to-remember, round number.
You may be aware that there is more than one way to calculate correlation; TradingBlox Builder, for example, provides two ways. So you will need to decide which correlation calculation to use. This is not a simple topic and it often inflames people's emotions (see (THIS) thread on another quant site for an example).
Because I have no idea what YOUR particular goals are when you run correlations, I also have no idea which calculation method is right for your particular application. That means: I don't know "the right answer" for the test cases presented here. It depends on what you are trying to do and how you are trying to do it.
However, I did choose the test cases so they will give wildly different answers ("The Correlation is X!") when you use the two different correlation calculations provided by TradingBlox. I hope this will help to sharpen the differences between the two alternatives, and thereby reassure you that you've chosen the best one for YOUR application.
Have fun with them!