# New Half Baked System



## LifeChoices (7 July 2011)

I've been shedding all my shares, some which I've held since 2007. I made roughly 5% plus dividends on my BHP shares that I bought way back on 9 October 2007.

Thinking there must be a better way, I began developing some software that would attempt to give me  a signal when to buy and sell.

The idea was that if during a certain time span if a share was to drop in price by a certain percentage I would buy it. I would sell it again when it either rises above that same percentage or when the price drops below my stop point. The idea would be that I would reinvest the profits back into the share price and see how much better I could do.

I just finished developing this software today and have experimented with various variables on my BHP shares bought on October 9 2007 to find out how much I could have made - the results surprised me a lot.

The best scenario I found would turn my starting capital of *$5,000* on 9 October 2007 into a jaw dropping *$75,846.24* on 31 March 2011.

Ok, these are the variables I used:

If during any 10 day period the share price of BHP dropped 4% I would buy.

I would only sell the shares if the shares went above 4% or if the price dropped below 30% of my purchase price.

All profits/losses would be re invested into the next buying opportunity.

In all transactions I used the days closing price and have included commsec commissions.

BHP only hit my stop point once on 30 September.

The attached spreadsheet shows all the transactions that would have occurred.

View attachment BHP.xls


----------



## sammy84 (7 July 2011)

I like that you're thinking outside the square, but there are flaws. Have only quickly glanced at your spreadsheet and note the following-

If your 30% loss comes early on the system is pretty much dead this put you a long way behind. You would then need a 42% gain to get back to B/E/. With your example your account had already gained 100% before the stop was hit. You might not always be so lucky.

One successful resource stock during a mining boom (granted your period included the GFC, but still had more boom years than bad) does not tell enough of the story. Would need to see this trial on a larger sample;


----------



## Sdajii (7 July 2011)

Try using the same system for the previous five years and see how it goes


----------



## LifeChoices (7 July 2011)

Sdajii said:


> Try using the same system for the previous five years and see how it goes




Probably would not be too much work for me to put the whole thing online and you can punch in your own variables for whatever stock.

The software spits out a csv file similar to the one I uploaded - which you can use as a sanity test.

All afternoon I've been trying all sorts of different variables - the stop percentage and profit/loss percentage are very sensitive, depending on the stock.

Fun all the same.


----------



## LifeChoices (7 July 2011)

LifeChoices said:


> Probably would not be too much work for me to put the whole thing online and you can punch in your own variables for whatever stock.
> 
> The software spits out a csv file similar to the one I uploaded - which you can use as a sanity test.
> 
> ...




Oh well back to the drawing board. I thought it was too good to be true. I found a serious bug with the dates and the calculations. 

There goes my evening.


----------



## AlterEgo (7 July 2011)

That spreadsheet appears to have errors in it. Eg. you sold on 9th May 08, so how could you buy back at 12 Nov *07*, an *earlier *date that it last sold? How can you reinvest shares that you haven't sold yet? I programmed this system in to Amibroker and get a very different result to what your spreadsheet shows.


----------



## LifeChoices (7 July 2011)

I found the problem and have sorted it out. 

The best I could have done is 138% profit over the period. If I had reinvested all my profits I would have been up over $10,000 on my original $5,000 investment. 

The settings I used were as follows:

Purchase BHP shares From 9 October 2007, when the share price drops at least 5% during any 10 day period.

Selling shares at 5% over the purchase price or when they hit my stop point of 30% below the purchase price. You can see the stop hit me on my third trade. 

Changing the percentages or the stop points even slightly causes major differences in the final outcome.

View attachment BHP.xls


----------



## skc (7 July 2011)

LifeChoices said:


> I found the problem and have sorted it out.
> 
> The best I could have done is 138% profit over the period. If I had reinvested all my profits I would have been up over $10,000 on my original $5,000 investment.
> 
> ...




Still something wrong. It appears you are selling at the day's high (or close) rather than selling at 5% profits. Basically you had done 26 trades with 1 loss so your P&L should be ~(1.05-0.002)^25 * (0.7-0.002)^1 = 2.25x. Assuming 10bps commission each way and no minimum commission.

So starting at $10K you end with $22.5K over 4 years, or ~23% each year. Not bad, but is it robust?




This table shows your return based on the above formula, with no. of trades across the columns and number of losses down the rows. The top table shows total return (e.g. in example above 26 trades and 1 loss gives 2.25x), while bottom table shows annual return assuming those trades are taken over 4 years (23% in above example) - I've highlighted all boxes >1 and >20% p.a. return.

The question comes down to whether you trust that your system will generate enough number of trades and low enough number of losses to make it worth your while. Indeed, your system needs a win rate of ~87% to break even...

I think there will only be a small number of shares that will work with this strategy. I.e. be volatile enough to generate the number of trades you are looking for, and be not too volatile to trigger your stop more than once or twice.


----------



## LifeChoices (7 July 2011)

I'm pretty sure it's all good now and will put it online.

The software currently uses the closing price of the day that the shares are bought, sold or stopped.

I used BHP and the date range as an example - only because I held this stock for this long and only made about 5% in four years. Pretty pathetic really.

Volitile stocks would work better with this system. The 5% profit/loss and 30% stop settings were optimal for BHP during this period. However, in saying that - most settings during the period did better than a stay and hold strategy.


----------



## AlterEgo (7 July 2011)

It's still different to what I get in Amibroker for some reason. For example, I get a buy on 5th Nov 07 instead of the 8th Nov that you get. The close on 5th is 43.70, which is more than 4% below the close 10 bars ago (45.92 on 22 Oct).

Another problem that I see is that the stop loss is triggered at 30% loss, but then re-enters on the very next day. What's the point in exiting one day if you're going to re-enter the very next day? I get 2 trades hitting the 30% stop rather than your 1. I get an entry on 26/5/08, hits stop on 30/9/08 for 33.56% loss, then re-enters the very next day on 1/10/08, then hits stop-loss again on the 20/11/08 for 35.57% loss. And then re-enters the next day on 21/11/08. I'm not sure why I'm getting entries on slightly different days to your entries.


----------



## AlterEgo (7 July 2011)

skc said:


> So starting at $10K you end with $22.5K over 4 years, or ~23% each year. Not bad, but is it robust?




Running it in Amibroker, assuming $20 commision per trade, I get only $78 profit overall.


----------



## AlterEgo (7 July 2011)

These are the trades I get.


----------



## LifeChoices (7 July 2011)

AlterEgo said:


> It's still different to what I get in Amibroker for some reason. For example, I get a buy on 5th Nov 07 instead of the 8th Nov that you get. The close on 5th is 43.70, which is more than 4% below the close 10 bars ago (45.92 on 22 Oct).
> 
> Another problem that I see is that the stop loss is triggered at 30% loss, but then re-enters on the very next day. What's the point in exiting one day if you're going to re-enter the very next day? I get 2 trades hitting the 30% stop rather than your 1. I get an entry on 26/5/08, hits stop on 30/9/08 for 33.56% loss, then re-enters the very next day on 1/10/08, then hits stop-loss again on the 20/11/08 for 35.57% loss. And then re-enters the next day on 21/11/08. I'm not sure why I'm getting entries on slightly different days to your entries.




It's interesting that Amibroker is doing that, because I think it's incorrect behaviour. 

My software first scans through the prices looking for buying opportunities. I've defined these as greater than a 5% fall during a 10 day period. I think the difference between what my software is doing and what Amibroker is doing is the following.

When I find a buying opportunity - the scan for the next buying opportunity is reset. ie: I find a buying opportunity on 25 October 07 and my next buying opportunity scan starts from the next day. The share price has dropped over 5% from 26 October 07 to 9 November 07.

What Amibroker looks like is doing is just getting all the buying opportunities regardless of the last buy date - that would explain buying the following day after being stopped, at a higher price - not a good idea. I would speak to them about it - that looks like a bug.

Does that make sense?


----------



## AlterEgo (8 July 2011)

LifeChoices said:


> It's interesting that Amibroker is doing that, because I think it's incorrect behaviour.
> 
> My software first scans through the prices looking for buying opportunities. I've defined these as greater than a 5% fall during a 10 day period. I think the difference between what my software is doing and what Amibroker is doing is the following.
> 
> ...




Well for starters, in your initial post you said 4%, which is what I prorgammed, now you're saying 5%, so that explains some of the difference.

Not a bug, i just programmed it as per your original post. You could certainly change the Amibroker code to reset the scan period if that's what you wanted to do. You never said you were doing it that way in your post so I didn't write it that way.

In any case, I think this system will never work in real life. You've curve fitted it to suit one particular stock over one time period. A robust system should work over a wide variety of stocks using the same parameters, and should work over different time periods, not just the period you've optimised it to.


----------



## LifeChoices (8 July 2011)

AlterEgo said:


> Well for starters, in your initial post you said 4%, which is what I prorgammed, now you're saying 5%, so that explains some of the difference.
> 
> Not a bug, i just programmed it as per your original post. You could certainly change the Amibroker code to reset the scan period if that's what you wanted to do. You never said you were doing it that way in your post so I didn't write it that way.
> 
> In any case, I think this system will never work in real life. You've curve fitted it to suit one particular stock over one time period. A robust system should work over a wide variety of stocks using the same parameters, and should work over different time periods, not just the period you've optimised it to.




Take it easy on those angry pills buddy. No need to scoff down the whole bottle.


----------



## AlterEgo (8 July 2011)

LifeChoices said:


> Take it easy on those angry pills buddy. No need to scoff down the whole bottle.




Not angry at all. Don't know what gave you that idea.

Also I read "greater than a 5% fall during a 10 day period" as being a rate of change of -5% over a 10 day period, ie. today's close as being 5% below the close 10 days ago. But now what I think you are really saying is 5% below the highest close in the last 10 day period. Is this correct? There's a number of different ways you could read that.

Anyway, I'm heading off to bed. Have wasted too much time looking at this already.


----------



## tothemax6 (8 July 2011)

Will this system involve any analysis of the potential future value of the stock?

Or are these sell rules just self-imposed gambling limits?


----------



## LifeChoices (8 July 2011)

AlterEgo said:


> Not angry at all. Don't know what gave you that idea.
> 
> Also I read "greater than a 5% fall during a 10 day period" as being a rate of change of -5% over a 10 day period, ie. today's close as being 5% below the close 10 days ago. But now what I think you are really saying is 5% below the highest close in the last 10 day period. Is this correct? There's a number of different ways you could read that.
> 
> Anyway, I'm heading off to bed. Have wasted too much time looking at this already.




It's not my fault your Amibroker software is buggy, I was just trying to help.

No one was twisting your arm and forced you to spend your time trying to prove me wrong. Anyway, what else would you be doing - losing money in shares?

Back to this stupid 10 day definition thing.

Let's just pretend I said a 2 day period rather than a 10 day period

*My software*

start date => nothing
day one => compare closing price of day one with start date if less than -5% stop
day two => compare closing price of day two with start date if less than -5% stop
day three => compare closing price of day three with day one if less than -5% stop
day four => compare closing price of day four with day one if less than -5% stop
day five => compare closing price of day five with day two if less than -5% stop
...
keep testing until true 
...
day thirty two => buy date
day thirty three => nothing
day thirty four => compare closing price of day thirty four with day thirty three if less than -5% stop

*Amibroker*

start date => nothing
day one => compare closing price of day one with start date if less than -5% stop
day two => compare closing price of day two with start date if less than -5% stop
day three => compare closing price of day three with day one if less than -5% stop
day four => compare closing price of day four with day one if less than -5% stop
day five => compare closing price of day five with day two if less than -5% stop
...
keep testing until true 
...
day thirty two => buy date
day thirty three => compare closing price of day thirty three with day thirty one if less than -5% stop
day thirty four => compare closing price of day thirty four with day thirty two if less than -5% stop

And you are complaining about wasting your time?


----------



## AlterEgo (8 July 2011)

LifeChoices said:


> It's not my fault your Amibroker software is buggy, I was just trying to help.
> 
> No one was twisting your arm and forced you to spend your time trying to prove me wrong. Anyway, what else would you be doing - losing money in shares?




I've actually been making good money in shares, even in this current market, but that's besides the point. Why are you being so aggressive towards me? I was only trying to help. I thought you'd appreciate another member verifying, or otherwise, your system with their software. Otherwise why else would you have started this thread if you're not interested in receiving any advice or feedback? Apparently you already have all the answers so I'll leave you to it.


----------

