[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] CORRELATION MATRIX: filter within loop ?



PureBytes Links

Trading Reference Links


Now THAT is pretty damned cool!  dirk schreiber <tianatrading@xxxxxxxxx> wrote:




does anybody know how to filter within loops?
 
i'm still playing around with the very nice CORRELATION MATRIX that came out of a group effort last month.
while visually it's nice to look at, i am having trouble trying to expand upon its functionality. 
i would like to be able to set a filter within the loop so that the matrix only shows those pairs with a correlation of higher than 0.75 for example. i have tried using "addcolumn(iif ...." and "iif( ... addcolumn" but that did not work. i understand that the for-loop overrides any filter within the loop? 
a question closely related is, i think, if it is possible to modify the code so that the correlation of any ticker would not be calculated against itself, because filtering within the matrix (if possible) for high correlation would not work, as every row has one incident of a perfect correlation of 1 (its own correlation).
below is a modified version of the code.
 
hope i made myself clear,
 
any help appreciated,
 
dirk
 

// Exploration to create Correlation matrix
Buy=Sell=Short=Cover=0; 
Filter = Status("LastBarInTest"); 
list = GetCategorySymbols( categoryWatchlist, 3 );
for( NumTickers=0; NumTickers < 100 AND StrExtract( list, NumTickers ) != ""; NumTickers++ ); 
IIf(C>50,AddTextColumn(Name(),"Ticker",1.0),0); 
for( Col=0; Col<NumTickers; Col++) 
{ 
Ticker1 = Name(); 
Ticker2 = StrExtract( list, Col); 
Var1 = Foreign(Ticker1,"C"); 
Var2 = Foreign(Ticker2,"C"); 
Corr = Correlation( Var1, Var2, 8 ); 
Color = IIf(Corr==1,colorBlack,IIf(Corr<-0.8,colorRed,IIf(Corr<-0.5,colorOrange,IIf(Corr<-0.2,colorLightOrange,IIf(Corr<0.2,colorCustom9,IIf(Corr<0.5,colorAqua,IIf(Corr<0.8,colorBrightGreen,colorGreen))))))); 
AddColumn( Corr, Ticker2, 1.3, 1, Color); 
} Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to suggest@xxxxxxxxxxxxx-----------------------------------------Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


Do you Yahoo!?Protect your identity with Yahoo! Mail AddressGuard
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing






Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.