Australian (ASX) Stock Market Forum

Unholy Grails - Amibroker

Joined
Jun 20, 2005
Posts
135
Reactions
0
After reading Nick Radge's Unholy Grails I was inspired to have a go at creating a system in Amibroker.

I've purchased Amibroker Pro and the historical ASX data from PremiumData.

Before having a go at my own system I thought I'd see if could replicate one of the systems in the book, just to make sure I've got some of coding basics down pat and the data setup correctly.

In the book they use PremiumData from 1/1/1997 to 30/6/2011 on the All Ords plus all delisted stocks. Starting with $100,000, including dividends & 20 positions of 5% each. 7 day liquidity and volume must exceed 500,00


I chose the bollinger band system to have a go at.
-use a 100 day moving average
-enter when the price crosses the 3 standard deviation band
-exit when price crosses the 1 standard deviation band

Having never used Amibroker I may be miles off, but this is what I came up with


Code:
SetOption("InitialEquity", 100000);
SetOption("MaxOpenPositions", 20);
SetTradeDelays(1,1,1,1);
SetPositionSize( 5, spsPercentOfEquity );


UpperBand = BBandTop( C, 100, 3 );
LowerBand = BBandBot( C, 100, 1 );

SevenDayAverageTurnover = MA(C*V, 7);
SevenDayAverageLiquidity = MA(V, 7);

Buy = Cross( UpperBand, C ) AND SevenDayAverageTurnover > 500000 AND SevenDayAverageLiquidity > 500000 ;
Sell = Cross( C, LowerBand ) ;

In the book the bollinger band system produced a CAGR of 33% with max drawdown of 43%.
My code attempt produces CAGR of 20% and max drawdown of 47%. I didn't expect to get a result exactly the same, but it seems a long way out.

I'm not including dividends as I don't know how you'd do that which would add a bit to the result. But at the same time, they are including delisted stocks in the book (which I'm not as the Premiumdata doesn't seem to contain this), so I should have made up some ground due to survivorship bias?

Any ideas where my code is going wrong?
Apologies for the long post.
 

rnr

Joined
Jul 1, 2007
Posts
563
Reactions
333
When need the CLOSE to be above the UpperBand when you Buy and below the LowerBand when you Sell.

Code:
Buy = Cross( C,UpperBand, ) AND SevenDayAverageTurnover > 500000 AND SevenDayAverageLiquidity > 500000 ;
Sell = Cross( LowerBand,C ) ;
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
All systems were tested using Montecarlo analysis. Those published would be the mean average.

If your only testing 1 pass of a portfolio then you won't get a complete range of worst to best to average.

Single pass tests will vary from run to run depending on the date the start and finish is set at.
Or which stocks are bought which will vary on portfolio size and available capital

Infact I'd be more concerned if you came up with the exact same result.
 
Joined
Jun 20, 2005
Posts
135
Reactions
0
Thanks rnr, that was a bad one
After making that change CAGR = 18% :(


Hi Tech
I gather that is your system in the book, TechTrader?

Do you have any good links on Monte Carlo Amibroker testing?

I tried adding

Code:
PS=Optimize("Postion Score",1,1,1000,1);
PositionScore = Random()*PS;
so it wasn't biased to picking stocks starting with A than Z, which produced a CAGR range of 17-20% compared to Nick's CAGR range of 18-39%, so obviously there is more to it than just a PositionScore.
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
Yeh the one traded on " The Chartist " for 7 yrs ---- still there!

I use Tradesim for Montecarlo testing it links with a lot of software.
 
Joined
Apr 24, 2009
Posts
26
Reactions
0
I'm interested in this book as well as back testing with AmiBroker (do not own either ATM).

Just wondering, do the tests take into account brokerage? If so what value do they use? I would think over 10+ years for 20 positions ($100k account) using brokerage of $30/trade will produce different results to $6/trade.... or is it a wash?
 

gav

Joined
May 20, 2008
Posts
1,158
Reactions
5
Just wondering, do the tests take into account brokerage? If so what value do they use? I would think over 10+ years for 20 positions ($100k account) using brokerage of $30/trade will produce different results to $6/trade.... or is it a wash?
The book uses brokerage of 0.25% per trade (with a minimum of $29.95)
 
Joined
Jan 24, 2008
Posts
10
Reactions
0
I emailed Premiumdata about delisted stocks and although they don't officially support delisted stocks for Amibroker due to code overlap issues (Amibroker can't handle a delisted stock and a listed stock with the same symbol), you can add them in with some limitations. When adding the delisted stocks using the method below delisted stocks will take preference where there is a same delisted/listed stock symbol.

To add delisted stocks:
File -> Database Settings
Click Configure
Click Add Folder
Navigate to C:\Trading Data\Stocks\Delisted Securities\ASX\MASTER, Click Retrieve Symbols, OK, OK.

My results for the Bollinger Band System AFL above (1 run, no position score)
Results from XAO (486 symbols)
CAR 15.37% and maxDD 45.06%

Results from XAO and delisted securities. (1508 symbols)
CAR 5.42% and maxDD 25.67%

(Criteria used for delisted securities, 3 character symbols that haven't traded in the last 100days)
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
1000 delisted securities?..
Something's wrong
 
Joined
Jan 24, 2008
Posts
10
Reactions
0
The delisted list I'm using is stocks that have stopped trading at some stage within the dates 01/01/1997 and 30/06/2012. (I just picked a date a few months ago) Over that time period does about 1000 stocks sound reasonable?

It is possible with my limited amibroker knowledge that something is wrong though :)
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
The delisted list I'm using is stocks that have stopped trading at some stage within the dates 01/01/1997 and 30/06/2012. (I just picked a date a few months ago) Over that time period does about 1000 stocks sound reasonable?

It is possible with my limited amibroker knowledge that something is wrong though :)
Sounds ridiculous.
When you say stopped
Stopped and never traded again or
Stopped and then continued to trade.
At a guess I'd say de listed and codes changed would be at most 100
 
Joined
Jan 24, 2008
Posts
10
Reactions
0
Stopped and never traded again. Just had a look through my list and they all seem to have stopped trading. (See attached)

I just did a bit of a search on google and there have been 67 delisted in the past 6 months, so I suppose it makes sense there have been over 1000 in the past 15 years. http://www.asx.com.au/asx/research/delistedCompanies.do

I don't however get as many as Nick Radge in his book, his test universe contains 1847 securities (XAO and complete delisted stock universe back to January 1997) Maybe because of the Amibroker code delisted/listed overlap issue? I'm not sure yet.
 

Attachments

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
Stopped and never traded again. Just had a look through my list and they all seem to have stopped trading. (See attached)

I just did a bit of a search on google and there have been 67 delisted in the past 6 months, so I suppose it makes sense there have been over 1000 in the past 15 years. http://www.asx.com.au/asx/research/delistedCompanies.do

I don't however get as many as Nick Radge in his book, his test universe contains 1847 securities (XAO and complete delisted stock universe back to January 1997) Maybe because of the Amibroker code delisted/listed overlap issue? I'm not sure yet.
If you have a good look you'll notice that only 15 have ceased
The remainder have been acquired in one way or another and
Are still trading under a different code.
This is generally done for you by a good data provider

You can now see where the difference is between your and Radges results.
 
Joined
Jan 24, 2008
Posts
10
Reactions
0
If you have a good look you'll notice that only 15 have ceased
The remainder have been acquired in one way or another and
Are still trading under a different code.
Yes that's correct, I want my list to include all of those.

In Unholy Grails the test universe is made up of the XAO plus complete delsited stock universe back to January 1997 including all stocks that have gone into administration as well as those delisted due to merger or acquisition. The test universe in the book has a total of 1847 securities.

So with my list I have about 500 XAO and 1000 delisted (stopped trading under that symbol) but that's still 300 less than the list used in Unholy Grails. Might have something to do with Amibroker not playing nicely with listed/delisted duplicated symbols but 300 difference is a lot. Any ideas on that one?
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
Yes that's correct, I want my list to include all of those.

In Unholy Grails the test universe is made up of the XAO plus complete delsited stock universe back to January 1997 including all stocks that have gone into administration as well as those delisted due to merger or acquisition. The test universe in the book has a total of 1847 securities.

So with my list I have about 500 XAO and 1000 delisted (stopped trading under that symbol) but that's still 300 less than the list used in Unholy Grails. Might have something to do with Amibroker not playing nicely with listed/delisted duplicated symbols but 300 difference is a lot. Any ideas on that one?
I'll ask Radge if I can get the list if you like
 
Joined
Apr 24, 2009
Posts
26
Reactions
0
Been looking at his site, particularly the subscriptions for the short term (turtle) and trend following systems.

Is his book an alternative for someone who wants to build, test and follow a similar system on their own? If so, does the book contain enough instruction for someone new to AmiBroker to navigate the software to do what's in the book?
 

rnr

Joined
Jul 1, 2007
Posts
563
Reactions
333
Been looking at his site, particularly the subscriptions for the short term (turtle) and trend following systems.

Is his book an alternative for someone who wants to build, test and follow a similar system on their own? If so, does the book contain enough instruction for someone new to AmiBroker to navigate the software to do what's in the book?
If you have been looking at The Chartist site then obviously you must have registered as a member so why don't you ask Nick this question...you will only get a "no bulls**t" answer?
 

tech/a

No Ordinary Duck
Joined
Oct 14, 2004
Posts
19,490
Reactions
3,792
Nicks reply to my email

For the book I used the default Delisted database and current XAO constituents as per the standard PremiumData subscription.

Now they have a new database, the Alpha PDU, which was not available at the time. This enables me to test the historical universes accurately. As an example, I can test the Small Ordinaries all the way back to 1991 using only those stocks which were ever in that universe at that exact time.

Nick Radge
AFSL 288200
 
Joined
Dec 21, 2010
Posts
240
Reactions
0
Nicks reply to my email

For the book I used the default Delisted database and current XAO constituents as per the standard PremiumData subscription.

Now they have a new database, the Alpha PDU, which was not available at the time. This enables me to test the historical universes accurately. As an example, I can test the Small Ordinaries all the way back to 1991 using only those stocks which were ever in that universe at that exact time.

Nick Radge
AFSL 288200
Sounds too good to be true. Where is this Alpha PDU, I can't find it anywhere on the Premium Data website?
 

Similar threads

Top