PureBytes Links
Trading Reference Links
|
Tomasz posted this code awhile back in answer to someone's
question on how to test for a set portfolio of stocks based
on the worst ROC performers from the pervious year, a "Dogs
of the Dow" type portfolio. My only modification was to add
the +1000 in line 10 to keep it from going short.
When I run this against a basket of stocks it picks 5 issues
for every year and it appears to select the correct ones.
However, when I run this against a watch list of the S&P
Select Sector ETF and a couple of other ETF type WL's I get
some years with 1 pick some with 3 etc. Also, it keeps
positions beyond the 1 year time frame as can be seen in the
attached picture. I can't seem to pinpoint the reason why it
doesn't work with this and a couple of other watch lists.
They all have data back to at least 2000. It is probably an
easy fix or reason but I am stumped for the moment. Any
pointers would be appreciated.
1.) numstocks = 5;
2.) EnableRotationalTrading();
3.) SetOption("MaxOpenPositions", numstocks );
4.) SetOption("WorstRankHeld", numstocks );
5.)
6.) PositionSize = -100/ numstocks;
7.)
8.) YearlyReturn = ROC( C, 252 );
9.)
10.) score = (1 / YearlyReturn)+1000; // lower return ->
higher score
11.)
12.) BeginningOfTheYear = Year() != Ref( Year(), -1 );
13.)
14.) PositionScore = IIf( BeginningOfTheYear, score ,
scoreNoRotate
Regards,
Duke Jones, CMT
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/86 - Release
Date: 8/31/2005
------------------------ Yahoo! Groups Sponsor --------------------~-->
Help tsunami villages rebuild at GlobalGiving. The real work starts now.
http://us.click.yahoo.com/njNroD/KbOLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Attachment:
amitest.png
Description: PNG image
|