Jeremy,
Here is a Correlation Matrix Code Contributed by
Herman Van Den Bergen and modified by me to make changing List to be tested and
lookback period adjustable thru the Parameters button in the Automatic
Analyser.
Instructions are at top of code.
Copy and paste the following code into the Formula
Editor.
Good Luck,
Greg
// Exploration to create Correlation matrix original by Herman Van Ven Bergen , Modified by
GB
// Be sure to set "Apply to" to desired wishlist name ( "use filter" "Define..."
)
// Also, change the watchlist number to the correct number (zero
based) as defined in "Apply
To"
// By adjusting Parameters in AA as well as LookBack period//
Buy=Sell=Short=Cover= 0;
Filter = Status("LastBarInTest");
Listnumber = Param("Listnumber",1,1,263,1);
LookBackPeriods = Param("Lookback Periods",3,1,252,1);
list = GetCategorySymbols( categoryWatchlist,
Listnumber);
for ( NumTickers=0; NumTickers < 99 AND StrExtract( list, NumTickers ) != ""; NumTickers++ );
AddTextColumn (Name(),"Ticker",1.0);
for ( Col=0; Col<NumTickers; Col++)
{
Ticker1 = Name();
Ticker2 = StrExtract( list, Col);
Var1 = Foreign(Ticker1,"C");
Var2 = Foreign(Ticker2,"C");
Test = Correlation( Var1, Var2, LookBackPeriods );
Color = IIf(Test>0,
colorGreen, IIf(Test<0,
colorRed, colorWhite));
Color = IIf(Ticker1==Ticker2, 1, color);
AddColumn( Test,
Ticker2, 1.3, 1, color);
}
----- Original Message -----
Sent: Wednesday, June 29, 2005 12:56
PM
Subject: [amibroker] help with simple
corelation marix
I have a watch list with 5 stocks. I am
trying to code a correlation matrix that reports the correlation for each
pair for the last 10, 30, 90, and 252 bars. I am new to AmiBroker
and have no clue on how to approach this one. Any help would be
greatly
appreciated.
Regards,
Jeremy
Please
note that this group is for discussion between users only.
To get
support from AmiBroker please send an e-mail directly to SUPPORT {at}
amibroker.com
For other support material please check also: http://www.amibroker.com/support.html
---- LSpots keywords ?>---- HM ADS ?>
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
---- LSpots keywords ?>
---- HM ADS ?>
YAHOO! GROUPS LINKS
|