PureBytes Links
Trading Reference Links
|
I have read as many threads about correlation as the yahoo search engine will give me before crapping out repeatedly and I am still puzzled on how to do the following.
from the AB help files:
// Correlation between Close price AND AND Close price 5 days back
Correlation( Close, Ref( Close, -5 ), 5 );
I am computing the monthly ROC from monthend to monthend for a fund and and index and would like to calculate the correlation of the entire array of fund ROC and index ROC across all the monthend data.
I am trying to do this as follows:
//Create an array with true on month end days
Monthend =Month() != Ref(Month(), 1);
//count how many month ending dates there are for the data
totmonths = Cum(Monthend);
//Find the array index value of the first month end day
startday = 0;
for(m = 0; m < 1; m++)
{
if (Monthend[m] == 0)
startday++;
}
Filter = Monthend;
fsym = Foreign( AnySymbol, "C" );
idxroc = 0;
symroc = 0;
totcount = 0;
//get a starting value on the first month end date for the fund and //the index
symprevval = C[startday];
idxprevval = fsym[startday];
//start a loop on the next day after the first month end date
for(d = startday + 1;d <= BarCount -1;d++)
{
if(Monthend[d] == 1) //It is a month end day
{
idxroc[totcount] = ((C[d]/idxprevval) - 1); //ROC from month end to month end and assign to an array
symroc[totcount] = ((fsym[d]/symprevval) - 1); //ROC from month end to month end and assign to an array
//record the current value as the previous value for the next loop calculations
idxprevval = C[d];
symprevval = fsym[d];
totcount++; //keep track of the total month end calc so far
}
}
Corr = Correlation( idxroc, symroc, -totcount );
// I have tried this one below as well with similar results.
//Corr = Correlation( idxroc, symroc, -1 );
AddColumn( Corr, "Corr", 8.5);
My problem is (I think), that I am trying to calculate a scalar while the Correlation function is calculating a vector. Not only that, but the exploration is returning a -1.#INFO value in the column. I am also not certain that the number the correlation function will return is a correlation of the entire range or if it is only calculating the correlation between each value and the value x bars back.
Jack
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|