Average Correlation - Index-Lab
Author: Christos
Creation Date: 3/27/2012 4:29 AM
profile picture

Christos

#1
I would like to create an index that would calculate the average correlation of the ROC of the closing prices of each symbol within a dataset vs the ROC of the closing prices of an external symbol. Is this possible using the Index Manager extention (suppose not)? Can u propose another way of doing that (if any)?
profile picture

Eugene

#2
When considering an Index Manager extension, the "external symbol" requirement is almost always a warning sign. The IndexDefinition API was designed with current DataSet in mind (only). Referring to an external symbol in the Index Manager is possible but that "hack" will require that you use System.Reflection to load the external Bars object. We do not have a sample code to illustrate the idea.

But if by "external symbol" you meant to say "another symbol from the same DataSet (on which the IndexDefinition is built on)", it would greatly simplify things. Is this what you're after?
profile picture

Christos

#3
Thanks for your instant reply Eugene,

I would like to implement exactly what you initially discribed in the first paragraph. However, if the external symbol is complicating things too much, a workaround would be to average the correlations among each possible pair within the same dataset. Would that be easier?

profile picture

Eugene

#4
For starters, how about creating the average correlation DataSeries using Correlation.Series from Community Indicators? That may turn out easier than building a new IndexDefinition.

Example: Sammy_G's excellent Correlation Matrix Strategy.

Would that get the job done, or you really need an IndexDefinition?
profile picture

Christos

#5
I would like to get the IndexDefinition since I want to use it in the "Analysis Series"
profile picture

Eugene

#6
Not a very straightforward task, but seems feasible:

1. Grab the demo project here: MS123 IndexDefinitions - Home

2. The SetIndexValues method -- the heart of any IndexDefinition -- is passed a list of Bars objects of the current DataSet from Wealth-Lab. Think of it as a DataSetSymbols replacement.

3. Assuming that all your symbols are already collected in a single DataSet (no external symbol access in IndexDefinitions), build a correlation matrix.

Correlation Matrix

4. There's no "main trading loop" in IndexDefinitions, so no need to loop bar by bar (Wealth-Lab does it in the background).

Average the correlation values, store the result in any (or all) DataSeries of the indexToDate object.


That's how I see it. Your mileage may vary.