I'm trying to calculate the average 60-day correlation of the daily returns of DJIA components with the daily returns of the index and I am using Norgate data with delistings. Any idea what I am doing wrong because this doesn't work?
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl"
wlnumber = CategoryFind("Dow Jones Industrial Average",categoryWatchList);
symlist = CategoryGetSymbols( categoryWatchlist, wlnumber);
nsymb=0;
sumcorr=0;
for ( i = 0; ( sym = StrExtract( symlist, i ) ) != ""; i++ )
{
FC=Foreign( sym, "C" );
cond= NorgateIndexConstituentTimeSeries("$DJI");
corr=IIf(cond, Correlation( C/Ref(C,-1)-1, FC/Ref(FC,-1)-1 , 60 ),0) ;
nysmb=IIf(cond, nsymb+1, nsymb);
sumcorr=sumcorr+corr;
}
avgcorr=sumcorr/nsymb;
Plot(avgcorr, "Avg 60-day corr of daily returns between index and constituents", colorBlack, styleLine);