# What do you  reckon about this trading strategy?



## Harro26 (16 December 2009)

Having thrown away 10s of thousands of dollars in 07-08 using a buy and hold strategy I finally realised that there must be a beter way of doing things. So I bought some books, started reading this forum and invested in some software. So far this is what I have come up with, it is still a work in progress and I am interested to hear peoples opinions (Good and bad) on this possible system. So far I am only about half way through developing this. The basic premise of the strategy is that there a 3 basic market phases, bull, bear and consolidating (Trading a range), since it is impossible to accurately predict which way the market will head I plan on using 3 strategies, one for each market type and bias my trading strategy towards what the current market is. I.e If in a bull market make 60% of trades using the bull system 20% using the bear system and 20% using the consolidating system etc. Ideally I want all 3 strategies to make money in all 3 markets but this is obviously proving difficult, so at the very least I want the losses to be minimal and the system to outperform the market. The one strategy that I would currently be happy to trade is the bull market strategy. It is based on the method used by the Turtles, that is get on board a trend and sell when the trend stops. It is very simple and has me buying in when a share hits a 22 day high and selling when it hits a 22 day low (Timings still to be optimised), there are a couple more simple rules but that is basically it (Seems maybe a little too simple but that's what I like about it). No stop loss is currently used but I am experimenting with this, if used it will be a fairly loose stop based on ATR as I have found a tight stop (at about 3-4 ATR) is not letting the profits run and getting me out of the stock early. So, this is the system that I am most interested to hear peoples opinions on. Being to tight to purchase Tradesim or some other system that can do MonteCarlo backtesting I have simply used Amibroker set the PositionScore to random and run 100 tests in the date range 17/09/2001 - 11/12/2009. The results are as follows:
Testing the ASX300 (All ords gives similar results, but if I trade this system I will be looking at the ASX300 for peace of mind)
XAO increase in this time - ~52%
Smallest Return using trend system - 111% (As in just over double)
Largest Return using trend system - 4746%
Average return using trend system - 1145%
Results from a typical Backtest are as follows:
Net Profit - 988%
Annual return - 33.55%
No of trades - 377
% winners - 34%
% losers - 66%
Avg profit - 46%
Avg loss - -10%
Max trade % drawdown - 50%
Max system % drawdown - 56%
CAR - 0.6
RAR - 0.67
Risk reward ratio - 0.79
Sharpe ratio - 0.28
K ratio - .0411

Good points from this data:
Large profit increase
Relatively small number of trades

Bad points form this data:
Everything else, in particular,
Win/Loss ratio - Low, usually a bit higher (about 40/60)
Trade and system draw downs - Large, these obviously occured in 07/08 so don't worry me too much, if my system evolves as desired I would pull most of my money out and put it into my bear system (When I perfect it/get it to a reasonable level). The system still consistantly outperforms the index during this period. Stop loss will also help this.
CAR/RAR - Based on system draw downs as mentioned above.
Sharpe and K ratio - Interested to hear opinions on these.

So like I said there are some bad points to the system and it would require alot of discipline to trade but it consistently out performs the market and at the end of the day it is annualised returns that I am looking for and this provides them. Things I am still working on:
Stop loss
Position sizing - Will look to set up such that it doesn't allow me to lose more that 2% of total equity based on the 22 day low at the time of purchase or on my stop loss.
If multiple buy signals are given on any one day I will use Fundamental Analysis (Mainly looking for EPS and profit increases over the last few reporting periods, agian, still working on it).
Sorry for all the words but I have found this forum to be invaluable in setting up and testing different strategies, it has pointed me to some good resources such as the chartist and different books and also my choice of trading software in Amibroker which has been great, hence why opinions from this site will be highly valued.

Cheers,

Harro


----------



## Wysiwyg (16 December 2009)

Harro26 said:


> *No stop loss is currently used but I am experimenting* *with this, if used it will be a fairly loose stop based on ATR as* *I have found a tight stop (at about 3-4 ATR) is not letting the profits** run and getting me out of the stock early*. So, this is the system that I am most interested to hear peoples opinions on.
> Harro



I have recently started experimenting with system backtesting. Backtests can be tricked up anyway one wishes. I can turn 10k into billions or I can crash it. Depends on what settings I use.


----------



## lukeaye (16 December 2009)

Hi harro,

thank you for sharing your ideas and system.

Can i ask you please, have you tested this system over;

(a) the last 10 months
(b) the last 2 years

If so what have your results been?

My next question is, how are you identifying whether you are in a bull, bear or range trading market?


----------



## lukeaye (16 December 2009)

Wysiwyg said:


> I have recently started experimenting with system backtesting. Backtests can be tricked up anyway one wishes. I can turn 10k into billions or I can crash it. Depends on what settings I use.




I want to know what superero will be on your Avatar next?

Im guessing Hulk?


----------



## Harro26 (16 December 2009)

Wysiwyg said:


> I have recently started experimenting with system backtesting. Backtests can be tricked up anyway one wishes. I can turn 10k into billions or I can crash it. Depends on what settings I use.




I agree, I have been very careful not to use any future data etc. Seems as I will only be trading after hours (Due work) I have set the settings to buy and sell at the open of the day after recieving a signal. I have accurately set up my commision rates etc. So, as far as I can tell, the backtesting should be 100% what I would have expected had I been trading the system. The obvious limitation is that I am using current day ASX300 data however I have backtested the All ords and results have been similar. I have seen a few strategies on the net (Including on this site) that when backtested give amazing results however when you delve into it there is a line of code in the buy signal stating buy = close > open, obviously with the settings set to buy on open you could achieve pretty impressive results using this. Other systems I have seen utilise the current days close to create and indicator but have you buying on the current days open. I am confident I have not done any of this.



lukeaye said:


> Hi harro,
> 
> thank you for sharing your ideas and system.
> 
> ...




Backtesing over the last 10 months gives a pretty consistent ~140% increase as compared with the XAOs 35% increase.

Backtesting over the last 2 years gives about a 100% increase as opposed to the XAOs 29% loss. It seems almost too good to be true for such a simple strategy hence why I am constantly searching for an error like mentioned above.

I do not currently have a mechanical system for determining if we are in a bull, bear or range trading market and would love to hear some suggestions. As such I am currently using the Marbo the constitution and the vibe. For example I believe we are currently in a range trading market, when the All Ords moves above 4900 I would switch to a bull market (Due previous resistance). If it drops to below 4500 I would call it a bear market (Due previous support).


----------



## nomore4s (16 December 2009)

Harro, can you post up a small sample of the trades from the backtesting?

With those types of results I'd say there is a glitch in there somewhere.


----------



## skc (16 December 2009)

lukeaye said:


> My next question is, how are you identifying whether you are in a bull, bear or range trading market?




Was going to ask the exact same thing. If you can program something on the overall market and overlay that with your 3 sub systems then it will take a good amount of guess work out of it.

And if you are keen to mix in fundamental analysis, you can always filter the stock universe by gearing ratio or no EPS growth less than -10% or something like that. It might improve your results?


----------



## Harro26 (16 December 2009)

nomore4s said:


> Harro, can you post up a small sample of the trades from the backtesting?
> 
> With those types of results I'd say there is a glitch in there somewhere.




Thanks for the feedback, that is what I'm worried about as it does seem too good to be true. That said, the Turtles obviously made millions trading a similar system. 
Attached is the charts showing the equity (Trading the ASX300) and the buy/sell signals (That would have been generated if trading only XAO) from early 2006. I have optimised the time paramaters to buy in at a 27 day high and sell at a 23 day low (This has been optimised based on data from 2001 not just the 06-09 period). I have also attached a sample of the trades. Is this what wou're after Nomore? Let me know if you want me to attach something else.

SKC, I'd like to incorporate something similar to what you've mentioned. I've only had Amibroker for a month or so but I don't think it can scan fundamentals (Requires more research). It may pay to invest in some software that does fundamental analysis. I'm currently reading How to make money in stocks (Don't like the title but the content is OK) by William O'Neil, he uses a method he calls CANSLIM which looks at accelarating EPS growth, Accelarating earnings increases, Volume, Institutional sponsorship etc. This fits in well with a trend following system so I am looking to incorporate these techniques into the system. I will allow the mechanical system to filter through the ASX300 and I will use the Fundamental method to determine which of these stocks are likely to perform best.


----------



## skyQuake (16 December 2009)

Your system uses the ASX300 index as entry and exits?
If you are trading intraday, beware of the staggered open.
Your system equity seems to refect the index moves heavily. Do a regression against the XAO and see how high the correlation is.

Cheers


----------



## Harro26 (16 December 2009)

Just realised that the list of trades I provided probably was not the most representative sample. As with any trend following system the majority of profits comes from a small sample of trades. So attached is the next group of trades


----------



## Harro26 (16 December 2009)

skyQuake said:


> Your system uses the ASX300 index as entry and exits?
> If you are trading intraday, beware of the staggered open.
> Your system equity seems to refect the index moves heavily. Do a regression against the XAO and see how high the correlation is.
> 
> Cheers




All trades occur at the open of the day after the signal is recieved so I would put in an order the night before when the market is closed, this is reflected in the backtesting. I assume this is what you mean by staggered opens.
Sorry, my post was a little misleading. The data I have provided is based on trading stocks in the ASX300 not the index itself. The graph of XAO shows when the system would have given buy/sell signals for the *index only* not the stocks in the index. 
Thanks.


----------



## Wysiwyg (16 December 2009)

The backtest settings are critical in my opinion. 

What amount of account is allocated to each trade? 100%
What amount of risk per trade? You mention no stop loss. So 100%


----------



## Wysiwyg (16 December 2009)

Have you tried Howards Bolly Bands formula? 

If not, could you give it a go and tell me what the results are like please? 

//   BBandBreakout.afl
//
//   A trend-following breakout system
//   based on the Bollinger Bands.
//
//   Buy when the closing price rises through the
//   upper Bollinger Band, Sell when the price
//   drops back into the Bollinger Bands.

PosQty = 4; // You can define here how many open positions you want
SetOption("MaxOpenPositions", PosQty );
PositionSize = -100/PosQty; // invest 100% of portfolio equity divided by max. position count

BBLookback = Optimize("BBLookback",12,2,30,2);
BBWidth = Optimize("BBWidth",2.8,1,3,0.1);
BBT = BBandTop(C,BBLookback,BBWidth);
BBB = BBandBot(C,BBLookback,BBWidth);
Buy = Cross(C,BBT);
Sell = Cross(BBT,C);
Short = Cross(BBB,C);
Cover = Cross(C,BBB);
e = Equity();
Plot(e,"Equity",colorBlack,styleLine);
//Figure 9.13 Bollinger Band Breakout


----------



## Harro26 (16 December 2009)

Wysiwyg said:


> The backtest settings are critical in my opinion.
> 
> What amount of account is allocated to each trade? 100%
> What amount of risk per trade? You mention no stop loss. So 100%




Position sizing is set at 10% of total equity, this is an arbitrary number and I plan on firming this up.
That's right there is no stop so risk is 100% of that trade, so therefore 10% of total equity.


----------



## Harro26 (16 December 2009)

Wysiwyg said:


> Have you tried Howards Bolly Bands formula?
> 
> If not, could you give it a go and tell me what the results are like please?
> 
> ...




No Probs,

I ran it straight away with my current settings and it gave a 33 digit profit. Like you say backtesting settings are critical and this is one of those methods where you must have your entry timing settings correctly. I had them set to buy on open and sell on open, naturally, I had a winning ratio of almost 100%. I changed the formula to that shown below:

PosQty = 4; // You can define here how many open positions you want
SetOption("MaxOpenPositions", PosQty );
PositionSize = -100/PosQty; // invest 100% of portfolio equity divided by max. position count
PositionScore = Random();
BBLookback = Optimize("BBLookback",12,2,30,2);
BBWidth = Optimize("BBWidth",2.8,1,3,0.1);
BBT = BBandTop(C,BBLookback,BBWidth);
BBB = BBandBot(C,BBLookback,BBWidth);
Buy = Ref(Cross(C,BBT),-1);
Sell = Ref(Cross(BBT,C),-1);
Short = Cross(BBB,C);
Cover = Cross(C,BBB);
e = Equity();
Plot(e,"Equity",colorBlack,styleLine);

This has you placing buy/sell orders during market close after recieving a buy/sell signal, thus the trade is executed at the following days open (With the entry/exit timing settings set to this). This give a less impressive return, ~70% loss. Using the original formula and setting it up such that trades are executed at close on the day the signal is generated gives an ~80-90% loss. I've examined the settings for my system 1000 times and am fairly confident that they are correct, unless there is any other common gotchas that people are aware of in Amibroker.
Thanks for the heads up though, I imagine that it is very easy to get some good returns during backtesting and get dollar signs in the eyes, only to start trading the system, lose alot of money and realise that you were using future data in your backtesting.


----------



## Wysiwyg (16 December 2009)

Harro26 said:


> This has you placing buy/sell orders during market close after recieving a buy/sell signal, thus the trade is executed at the following days open (With the entry/exit timing settings set to this).



 I thought the "settings" in Auto Analysis were the final criteria that the analyser uses when back testing. 

Buy and Sell on market open.

The formula says Buy cross Bollinger Band Top. So if the settings in Auto Analyser are 'Buy open' then that would be a buy on the market open. 

Same with Sell Bollinger Band Top cross. Signal initiates a sell so when the market next opens the sell is executed.

This could be wrong.


----------



## Harro26 (16 December 2009)

Wysiwyg said:


> I thought the "settings" in Auto Analysis were the final criteria that the analyser uses when back testing.
> 
> Buy and Sell on market open.
> 
> ...




We may be saying the same thing but just to clarify. Using the BBand formula as an example:
You are buying when the price closes above the top BBand line, if you have the settings in automatic analysis set to buy on open this is incorrect. If the price closes above the top BBand line the price is more than likely (I won't say certainly) going to rise from open to close, therefore you are using the close price to generate a signal and than telling it to buy on open. You could write a formula saying buy = close > open, sell = close > open and set the settings to buy on open and sell on close, you would have a winning percentage of 100% and make billions according to the backtester.
In my system, I will be examining the buy signals at night when the market has closed and placing orders for the next days open. To replicate this in the backtester I have said:
Buy = Ref(Close > Ref(HHV(Close,27),-1),-1)
The ref(HHV(close,27),-1) is such that it is looking at the previous day for the highest high value in 27 days (Otherwise it would never generate a buy signal as the current days high would be equal to the 27 day HHV not greater than (I probably could have solved this by making it equal to  instead of greater than, but it's done now))
The ref(..........,-1) that encompasses the whole formula is to satisfy the backtester. I set the settings to buy and sell at open and using the ref function it is buying or selling at open the day after the signal is generated.

I hope that made sense.


----------



## Wysiwyg (16 December 2009)

Harro26 said:


> I hope that made sense.



Yes it did thankyou.


----------



## chesl73 (16 December 2009)

Harro26,

Instead of doing the Ref(...,-1), could you try this:
SetTradeDelays(1,1,1,1); //ie, look at data today then buy tomorrow on open
BuyPrice = SellPrice = Open;
Buy = Close>= Ref(HHV(Close, 27), -1);

As I understand it, this says
- after close of today, check buy signals, ie, you come home from work and it run this and it generates a buy if Close is made over last 27 days. However, the actual buyprice is tomorrow on open.
See what results you get with this.

Your returns do seem a bit high for a basic high > high last 27 days. Also, the drawdowns are very high, could you physcologically (excuse the spelling!) handle this sort of drawdown? Wouldn't you keep 2nd guessing yourself whether you've coded your system accurately (as you're doing now) when you start losing a lot of money?
If you then put stops on the system you will most likely reduce your return so it's a always a tricky balance.


----------



## Wysiwyg (16 December 2009)

Harro26 said:


> SKC, I'd like to incorporate something similar to what you've mentioned. I've only had Amibroker for a month or so but *I don't think it can scan fundamentals* (Requires more research). It may pay to invest in some software that does fundamental analysis.



If you are still around. This is a stock scanner that isolates your chosen criteria from the XAO. It will give up a stock list and then you have a universe of stocks that meet the fundamental criteria. Not brilliant but it narrows down the field. I also use it to create a universe of pennies under 20c for example.

http://www.ascii-data.com/index.html


----------



## Julia (16 December 2009)

Wysiwyg said:


> If you are still around. This is a stock scanner that isolates your chosen criteria from the XAO. It will give up a stock list and then you have a universe of stocks that meet the fundamental criteria. Not brilliant but it narrows down the field. I also use it to create a universe of pennies under 20c for example.
> 
> http://www.ascii-data.com/index.html



That's useful, Wysiwyg, thank you for posting this.


----------



## Harro26 (18 December 2009)

Thanks all for your responses. I have tidied the code up a little now and the returns are not so impressive but still good. I have got rid of the ref(.......,-1) and used settradedelays(1,1,1,1), thanks Chesl. I think that using multiple ref(....,-1) in the same line may have been tricking the system some how. I have also changed Buy = Ref(Close > Ref(HHV(Close,time),-1),-1)
to Buy = Close == HHV(Close,time) and a few other things like that. Returns since 2001 are now as follows:
Highest 1800%
Lowest 280%
Average - around the 700% mark

Still good returns so I will not trade the system until I am 100% confident that there are no bugs in it.
The above results were obtained using a Pseudo Monte Carlo method in Amibroker that I came up with. It is posted in the Software section of this forum and I reckon it's pretty good (If I may say so myself)


----------



## Wysiwyg (18 December 2009)

chesl73 said:


> Harro26,
> 
> Instead of doing the Ref(...,-1), could you try this:
> SetTradeDelays(1,1,1,1)



Could anyone explain what each 1 in brackets represents please. Obviously one 1 is a trade open delay of one day.


----------



## captain black (18 December 2009)

Wysiwyg said:


> Could anyone explain what each 1 in brackets represents please. Obviously one 1 is a trade open delay of one day.




SetTradeDelays (Buy,Sell,Short,Cover);


----------



## Wysiwyg (18 December 2009)

captain black said:


> SetTradeDelays (Buy,Sell,Short,Cover);



Thankyou.


----------



## brty (18 December 2009)

Harro,

How about you run the tests on the stocks that were in the ASX300 in 2000 rather than those in the ASX300 now, to rid yourself of survivorship bias. It may also have a big impact on drawdowns.

Another weakness in this type of testing is the ability to actually implement all the trades at those prices. For example, one of your biggest wins was on RIV, bought on 21/7/2006 for .92, sold 23/1/2007 for 1.95. Yet on 21/7/2006 only 103,900 shares were traded and on 23/1/2007 only 321,000 shares were traded. To overcome relatively large costs associated with brokerage, your trading size would have to be large enough to greatly affect the opening prices, probably by quite a few cents on both the purchase and sale.

It is all the little annoying realities of the market that make this type of system seem so good on paper, yet fail in the real world.

brty


----------



## Chorlton (18 December 2009)

skyQuake said:


> Your system uses the ASX300 index as entry and exits?
> If you are trading intraday, beware of the staggered open.
> Your system equity seems to refect the index moves heavily.* Do a regression against the XAO and see how high the correlation is.*
> 
> Cheers





Hi SkyQuake,

Could you explain how this would be achieved?


Thanks,


----------



## Harro26 (18 December 2009)

brty said:


> Harro,
> 
> How about you run the tests on the stocks that were in the ASX300 in 2000 rather than those in the ASX300 now, to rid yourself of survivorship bias. It may also have a big impact on drawdowns.
> 
> ...




Hi brty,

I have thought about this but wouldn't know where to look. Do you know where I could find the 2003 ASX300? The best I have done is test it against all symbols in AB and it still gives a pretty good return.
There are always going to be problems with paper trading a strategy and you won't really know how it will perform until you actually dive in and try it for real. Backtesting gives you a reasonable indication and is an essential step prior to trading a system. No matter how good a trading strategy appears you can always be spooked away from the market due to nuances as mentioned above but if the stategy looks good on paper it is the best bet I have to go on.
For info, the maximum amount that I will commit to a trade is going to be a ratio of the average volume over a recent time period. I haven't worked out the details yet (I have read about it in a book but I can't remember which one) and my next step is to do this and see if I can write it into Amibroker to give more accurate backtesting.

Harro


----------



## captain black (18 December 2009)

Harro26 said:


> For info, the maximum amount that I will commit to a trade is going to be a ratio of the average volume over a recent time period. I haven't worked out the details yet (I have read about it in a book but I can't remember which one) and my next step is to do this and see if I can write it into Amibroker to give more accurate backtesting.Harro




In the AA settings box under the "Portfolio" tab is an option to limit the trade size as a percentage of entry bar. It may do what you want without the need for complex code.



> _Limit trade size as % of entry bar volume_
> This prevents from entering the trades greater than given percentage of entry   bar's volume.    For example if backtesting daily data and today's volume for thinly traded   stock is 177,000 shares, setting this to 10% will limit the maximum trade size   to 17,700 shares (10% of total daily volume). This prevents from 'affecting   the market'  by huge orders.



System test settings window
http://amibroker.com/guide/w_settings.html


----------



## Harro26 (19 December 2009)

Wysiwyg,

these are the results you were after in the other forum.
Period tested 1/4/2007 - 1/12/2008.
All trades were long.
XAO performance in this time -39%
I ran 100 tests against the ASX300 and the results are as follows:
Average return -19.56%
Best return -2.11%
Worst return -32.55%
Obviously a negative return but still better than the All Ords. I have run it from the start of the crash to now and the results are actually a positive return.

Against all fully paid ordinary shares the results are alot worse and are as follows:
Average return -52%
Best return -26%
Worst return -70%

This is why I am trying to find historical ASX300 lists as it may be this unreality inflating returns. I'll post on this site to see if anyone has this list.


----------



## Wysiwyg (19 December 2009)

Harrow, I used the same time as you*17/9/2001 to 11/12/2009* with start up capital of 100k, 10 positions opened max., $30 brokerage, only long, min. 100 shares, min. pos. value $500, buy/sell on open and only the systems algorithms to open and close trades. (all stops disabled)

Max. system drawdown -35193.48 
Max. system % drawdown -12.76 %


----------



## Wysiwyg (20 December 2009)

Wysiwyg said:


> Harrow, I used the same time as you*17/9/2001 to 11/12/2009* with start up capital of 100k, 10 positions opened max., $30 brokerage, only long, min. 100 shares, min. pos. value $500, buy/sell on open and only the systems algorithms to open and close trades. (all stops disabled)
> 
> Max. system drawdown -35193.48
> Max. system % drawdown -12.76 %



Oh dopey me. I forgot to change the formula to PosQty = 10 and the PositionScore = Random. Was 4 positions and ranking. 
The results are much more impressive.

Max. system drawdown -63624.76 
Max. system % drawdown -9.81 %


----------



## Harro26 (20 December 2009)

Those are some good results Wysiwyg. I like the win/loss ratio. Are you using a similar trend trading strategy to what I am using or something else?


----------



## Wysiwyg (21 December 2009)

To hold trades for a fixed n bars before allowing formula to exit trade, then this code does that. Something I experimented with and had extremely varied results. Pending on n day bars held (e.g. 5, 10, 20 or 50) and date range back tested. Better results for a longer hold in a bull run with this strategy. 

Example:

SetOption("HoldMinBars", 127 );
Buy=BarIndex()==0;
Sell=1;
// even if sell signals are generated each day,
//they are ignored until bar 128 


> Are you using a similar trend trading strategy to what I am using or something else?



 It is different.


----------

