Correlation Table for Amibroker (AFL)
genkumag over 14 years ago Amibroker (AFL)
Using the analysis feature in Amibroker, one can compare degree of correlations between and across securities found in a filtered watch list. This Amibroker code was prepared by the Quanting Dutchman last year.
Just edit the CorrPd line in the formula and specify the period of correlation you’re trying to analyse.
Screenshots
Indicator / Formula
// eCorrelationTable.afl
WLNum = Param("WatchlistNr",0,0,255,1);
CorrPd = 21;
list = GetCategorySymbols( categoryWatchlist, WLNum);
SetOption("NoDefaultColumns",True);
Filter = DateNum()==Status("rangetodate");
//SetSortColumns( 2 );
AddTextColumn(Name(),"Corr("+NumToStr(Corrpd,1.0)+")",1.0,width=70);
Ticker1= Name();
for( Col=0; (Ticker2=StrExtract( List, Col))!= ""; Col++)
{
Var2 = Foreign(Ticker2,"C");
Corr = Correlation( C/Ref(C,-1), Var2/Ref(Var2,-1), CorrPd);
Color = IIf(Corr>0.5, colorLime, IIf(Corr>0,colorBrightGreen,IIf(Corr<-0.5, colorRed,IIf(Corr<0,colorOrange,colorWhite))));
Color = IIf(Ticker1==Ticker2, 1, color);
AddColumn( Corr, Ticker2, 1.3, 1, Color,width=60);
}2 comments
Leave Comment
Please login here to leave a comment.
DID NOT WORK
What type of co-relations we are talking about, metal stocks to companies using those metals? and automobile companies? Something like that?