Hi Thomaz,

i have been trying to figure out this code for several weeks.  I am 
stuck.  Hopefully you can help me.  I am trying to modify the 
corelation matrix to output the results to a csv file.  I have not 
been able to get every paird correlation written to the csv.  I would 
also like to be able to add a filter before weiting out to the csv 
for example corr>=.75;

here is the code so far: 


WLNum = Param("WatchList Number",6,0,500,1);
CorrPd = Param("Correlation Period",1000,1,5000,1);
list = GetCategorySymbols( categoryWatchlist, WLNum);
Listname = CategoryGetName( categoryWatchlist, WLNum ); 
Yea = Year();
Mon = Month();
Daz = Day();
Dh = StrFormat("%02.0f%02.0f%02.0f", Mon, Daz, Yea );
fh = fopen("E:\\Program 
Files\\AmiBroker\\Test\\ "+"Pairs_"+Dh+"_"+Listname+".csv", "w");
fputs( "Ticker 1,Ticker 2, Correlation \n", fh ); 
WLNum = Param("WatchList Number",27,0,500,1);
CorrPd = Param("Correlation Period",1000,1,5000,1);
list = GetCategorySymbols( categoryWatchlist, WLNum);
SetOption("NoDefaultColumns",True);
Filter = Status("LastBarInTest");
SetSortColumns( 1 );
AddTextColumn(Name(),"Correlation",1.0);
Ticker1= Name();
for( Col=0; (Ticker2=StrExtract( List, Col))!= ""; Col++)
{
Var2 = Foreign(Ticker2,"C");
Corr = Correlation( C, Var2, CorrPd);
Output = ticker1 + ","+ Ticker2+","+Corr+"\n";
fputs(Output,fh);
Color = IIf(Corr>0, colorBrightGreen, IIf(Corr<0, 
colorRed,colorWhite));
Color = IIf(Ticker1==Ticker2, 1, Color);
AddColumn( Corr, Ticker2, 1.3, 1, Color);
}
fclose(fh);

your help is greatly appreciated



Reply via email to