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

RE: [amibroker] Studying indexes & comparing movement



PureBytes Links

Trading Reference Links

This Exploration get you started. Take note of the starting dates of the two
indices and that of the current stock, the current stock may have to have
more bars than the indices to list things properly. Perhaps somebody else
can comment on this.

Good luck,
Herman.

Buy=Sell=Short=Cover=0;
Filter = Status("LastBarInTest"); // use this line to see only the last bar
Filter = 1; // use this line to list each bar
SetOption("NoDefaultColumns",True);

Index1 = Foreign("!NDX","C");		// substitute your own indices
Index2 = Foreign("!COMP","C");

// Note that some days there may be no change
Up1 = ROC(Index1,1) > 0;
Up2 = ROC(Index2,1) > 0;
Dn1 = ROC(Index1,1) < 0;
Dn2 = ROC(Index2,1) < 0;

// Note that the current stocks must have more bars than the indices you are
testing...
NumBars = BarCount;

//note that Cum() works from the very first bar up
PercentUp1 = (Cum(Up1)/NumBars)*100;
PercentUp2 = (Cum(Up2)/NumBars)*100;
PercentDn1 = (Cum(Dn1)/NumBars)*100;
PercentDn2 = (Cum(Dn2)/NumBars)*100;

AddColumn(NumBars,"#Bars",1.0);
AddColumn(Cum(Up1 AND Up2),"BothUp",1.0);
AddColumn(Cum(Dn1 AND Dn2),"BothDn",1.0);
AddColumn(Cum(Up1),"#Up1",1.0);
AddColumn(Cum(Dn1),"#Dn1",1.0);
AddColumn(PercentUp1,"%Up1",1.2);
AddColumn(PercentDn1,"%Dn1",1.2);

AddColumn(Cum(Up2),"#Up2",1.0);
AddColumn(Cum(Dn2),"#Dn2",1.0);
AddColumn(PercentUp2,"%Up2",1.2);
AddColumn(PercentDn2,"%Dn2",1.2);















-----Original Message-----
From: C. Brennan [mailto:cjb123@xxxxxxxxxxxxx]
Sent: Saturday, August 09, 2003 8:12 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Studying indexes & comparing movement


Hello:

Can you please offer some code to help me BACKTEST the following
EOD situation:

if index A is up and index B is also up
OR
if index A is down and index B is also down
then
message = "matching indexes"
else
message = "non-match"

I'd like to run this code as a backtest on two indexes and count the
number of times in the past the indexes moved in sympathy with one
another.

Thank you!




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 http://docs.yahoo.com/info/terms/



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/