New Mean Reversion Trading System (Stocks Over 50 day MA) Tested in Amibroker

This week we put a broader market Mean Reversion trading system to the test.  It was called out by Chris Weston on the ASX market last August as markets around the world were melting down.

Does it work?  We go back over the last six years (that Chris had mentioned), and then the last 15 years using a Monte Carlo test of 1000 random runs to thoroughly check it and see if we would trade it.

The Trading System Rules

The rules state that when fewer than 10% of ASX Top 200 stocks are above their 50 Day Moving Average, then that is (historically) a good time to buy.

In other words – most of the stocks on the index are moving downwards – technically a Mean Reversion trading system (like a “contrarian” system, that buys when stocks are falling in the hope that they will recover to their average).

We can actually test this using a little trick we learned a few weeks ago – AddToComposite in Amibroker.  AddToComposite adds stocks to our very own index.  In this case, we’re looking at add stocks that are over their 50 day Moving Average.

We then want to turn it into a trading system, so we can buy a basket of stocks when our index goes below, say, 30 (if we’re looking for 10% of ASX 200, including delisted stocks and giving a bit of lee-way).

So I’ve made it:

  • Buy when our “Stocks Over 50 day MA” index crosses below, then back above 30
  • Buy 20 stocks randomly, with 5% in each
  • Hold for one year, then sell

Check out the video below for the results!

We tested on:

  • The ASX Top 200
  • From 2000 to 2015
  • Monte Carlo, 1000 Random variations of the test

Results from 2009 to 2015 were:

  • 24% per year return
  • 16% maximum drawdown

Results from 2000 to 2015 using Monte Carlo testing were:

  • 11% per year return
  • 30-50% maximum drawdowns

As you can see, it is often worthwhile testing properly, just in case we get another “2008” scenario, where this system really fell apart.

Happy trending!

– Dave McLachlan

  1. Stock Market Research: The REAL Effect of “Buy and Hold”
  2. This Simple Indicator SMASHES “Buy and Hold” Returns!
  3. More Stats on the Indicator that Beats Buy and Hold Returns
  4. New Mean Reversion Trading System (Stocks Over 50 day MA) Tested in Amibroker
  5. How This Random Entry Beat The Market (The Tom Basso Coin Flip Proven & Explained)
  6. Does the “Golden Cross” Outperform Buy and Hold? Market Timing, Real Results
  7. The Trading System from “Reminiscences of a Stock Operator”, Tested Over 116 Years
  8. The Three Billion Dollar Day Trading System Revealed and Tested

December 13, 2015  Tags: , , , , , , ,   Posted in: Stock Market Research

6 Responses

  1. John - January 6, 2016

    Hi Dave,

    I love your videos and they have helped me a great deal. I have a question regarding the Amibroker coding for the entry to a system where you first have a trigger and then the buy is dependent on the price action the next day. For example, lets say the trigger is two lower closes so the close for today is less than the close for yesterday and the close for yesterday is less than the close for two days ago. The entry is tomorrow but only if price trades higher than today’s high plus 2 cents. Any assistance will be greatly appreciated. Thanks a million in advance.

  2. David McLachlan - January 6, 2016

    Hey John,

    Thank you!

    And of course. I reckon this is definitely possible. Now, there might be an easier way to do it, but if it were me I would use “Ref(Array, Lookback number)”. For example, to REFER to the close two days ago, would be “Ref(C, -2)”. Then, those lower closes of yours might look like: “C < ref(C, -1) AND ref(C, -1) < ref(C, -2)". Just as an example. There's an article here on it - if you search for "ref" it will come up 🙂 Happy trending! Dave

  3. John - January 6, 2016

    Thanks for prompt reply Dave, I really appreciate the fact that you have taken time out to reply to my query. The setup or trigger is not the problem. It is the entry day. So lets say that the setup has triggered today, that is C<ref(C,-1) and ref(C,-1)< ref(C,-2). In your videos the entry is on the open the next day. However, I would like to know how to code the entry being enter tomorrow only if today's high is exceed by 2 cents? Is this possible?

    Cheers, John

  4. David McLachlan - January 7, 2016

    Hmmm – it is. Time and Price are the main items in a trading system (on a chart, anyway), and Amibroker can look at any part of those two things.

    As for how to do it – my coding skills are basic, but I can tell you a few steps that I might go through.

    First, for me I would make the shift in timeframe. You mention entering tomorrow. In reality, “Tomorrow” is always in the future, so I would personally shift the whole thing forward one day so I could really test it as if I were trading it.

    If you were willing to do that, it would look like:
    * Enter TODAY if price is 2c higher than yesterday’s high
    Or something like: H > (ref(H, -1) + 0.02) …
    * AND ref(C, -2) < C

  5. David McLachlan - January 7, 2016

    I would also set “Trade Delays” to “0” in Settings, for the trade to be logged on the day I get the signal.

    Then, if you wanted the “Buy Price” to be 2c higher than yesterday’s close (unless of course, it OPENS above that level), it might be:

    BuyPrice = IIF(Open > (ref(H, -1) + 0.02), Open, ref(H, -1) + 0.02);

    I think. You’ll have to have a play with it – as I’m not sure if BuyPrice is restricted to OHLC and Avg only. There’s a vid on IIF here too (and it might be worth doing a video on BuyPrice, maybe?). Hope this helps.

    Cheers – Dave

  6. John - January 7, 2016

    Hi Dave,

    Very helpful, thanks again.

Leave a Reply