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

[amibroker] CORRELATION MATRIX: filter within loop ?



PureBytes Links

Trading Reference Links




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<FONT 
size=2>=Sell=Short=Cover=0; 

Filter = <FONT 
color=#0000ff>Status("LastBarInTest"); 

list = GetCategorySymbols( 
categoryWatchlist, 3 );<FONT 
color=#800000>
for( NumTickers=<FONT 
color=#ff00ff>0; NumTickers < 100 AND <FONT 
color=#0000ff>StrExtract( list, NumTickers ) != <FONT 
color=#ff00ff>""; NumTickers++ ); <FONT face=Verdana 
color=#0000ff>
IIf<FONT 
face=Verdana>(C>50<FONT 
face=Verdana>,AddTextColumn(<FONT 
color=#0000ff>Name(),"Ticker",<FONT 
color=#ff00ff>1.0),<FONT face=Verdana 
color=#ff00ff>0); <FONT 
color=#800000>
for( Col=<FONT 
color=#ff00ff>0; Col<NumTickers; Col++) 
{ 
Ticker1 = Name(); 
Ticker2 = StrExtract( list, Col); 

Var1 = Foreign(Ticker1,<FONT 
color=#ff00ff>"C"); 
Var2 = Foreign(Ticker2,<FONT 
color=#ff00ff>"C"); 
Corr = Correlation( Var1, Var2, <FONT 
color=#ff00ff>8 ); 
Color = IIf(Corr==<FONT 
color=#ff00ff>1,colorBlack,<FONT 
color=#0000ff>IIf(Corr<-<FONT 
color=#ff00ff>0.8,colorRed,<FONT 
color=#0000ff>IIf(Corr<-<FONT 
color=#ff00ff>0.5,colorOrange,<FONT 
color=#0000ff>IIf(Corr<-<FONT 
color=#ff00ff>0.2,colorLightOrange,<FONT 
color=#0000ff>IIf(Corr<<FONT 
color=#ff00ff>0.2,colorCustom9,<FONT 
color=#0000ff>IIf(Corr<<FONT 
color=#ff00ff>0.5,colorAqua,<FONT 
color=#0000ff>IIf(Corr<<FONT 
color=#ff00ff>0.8,colorBrightGreen,colorGreen))))))); 

AddColumn( Corr, Ticker2, <FONT 
color=#ff00ff>1.3, 1, Color); 
} 






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.




Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard