Free Trading System Rules
I want to take this opportunity to show you a simple trading system for stocks that I developed a few years ago that still performs pretty well today.
This is a trend following system for stocks and it's what you might call a longer term strategy. Basically, it looks to ride trends for weeks or months at a time.
Because it's made up of just a few, very simple rules you could say that it's pretty robust. In this article, I'm going to show you the full rules and I'm going to show you the full back-test results for this strategy. You'll also be able to download the Amibroker code.
Now, I can't guarantee this system will continue to perform in the future because the future is never known and past performance is not always a reliable indicator for future returns (make sure you read the full disclaimer).
So, I definitely don't recommend you put all your eggs into this one particular model. But if you're like me and you're fascinated with testing new trading ideas then this simple system should definitely interest you.
A Simple System For Stocks
This system is designed to trade trends in S&P 1500 stocks and it can hold up to 8 stocks at any one time. It's long only, meaning it only enters long trades and never goes short. It uses a simple moving average crossover to find trends and it trades on weekly timeframes.
This means it's the kind of investment strategy that can be implemented without spending too much time watching the charts. Let's look at the basic buy and sell rules:
There we have it. Three very simple rules for picking upward moving shares.
We are going to buy a stock from the S&P 1500 and add it to our portfolio when its 10-week moving average crosses over its 18-week moving average. This signals that an upward trend in the stock is in place.
We then sell the stock from our portfolio when the 10-week moving average crosses back under the 18-week moving average. This signals that the upward trend is now over.
In addition, we can only take new long positions if the 50-week moving average on the S&P 500 index is sloping upwards. This indicates that the broader market is also in an upward. This is known to system traders as a type of market timing filter and it helps us to avoid nasty bear market periods.
Crucially for this system, all of our moving average indicators are calculated using the open price and we will use the close price to enter our trades.
This important factor will help us to get on board the trends early.
99% of people use the close price to calculate their moving average signals and then they trade on the next bar open. By using the open price to calculate the moving average we can beat them to it by trading earlier.
You might be thinking now that such simple rules cannot possibly do all that well.
As we shall see, the devil is in the details. To really get this system moving we need to include some important liquidity, risk and portfolio rules. After all, no trading system will work well if we enter large positions in illiquid stocks or bet too much capital per trade.
So let's take a look at some additional details:
Now that we have specified these additional details we are in a position to test this strategy on some historical data. This will give us a good idea of the system's potential.
To do so we need some software with realistic back-test settings and we also require some reliable historical data.
Our simulation environment is now set up. We can now describe this strategy in plain language so that it is fully understood.
Strategy In Plain Language
Our initial equity will be $100,000 and our capital will be weighted equally between a maximum of eight open positions. That means this is an equal weighted portfolio where each trade uses 12.5% of our equity with no margin used.
This is a long only system (meaning no short positions) and it uses weekly charts.
Anytime after Monday morning's open, we scan the S&P 1500 universe for any stocks that have a MA crossover.
Whenever we find a stock where the 10-week MA has crossed over the 18 week MA, that signals a new uptrend so we are going to buy that stock and add it to our portfolio.
Whenever the 10-week MA crosses under the 18-week MA, it signals the uptrend is over and we are going to sell the stock and it will drop off the portfolio.
We are only allowed to enter long trades when the 50-Week moving average on the S&P 500 is also sloping upwards and all our trades will all be placed on the weekly close using market-on-close orders (MOC).
Remember, that our moving averages are all calculated using the open price - many chart platforms are able to do this now and this allows us to trade earlier than those using closing prices.
In addition to all this, we also need a ranking rule.
Often, when the market is in a strong uptrend we will get more than one trading signal (more than one MA crossover) and we might not have space in the portfolio for all of them. So we need a way to choose between them.
For this system, if we encounter more than one signal, we are going to prefer the stock with the highest RSI(14) value on the previous bar. (RSI stands for the Relative Strength Index indicator and was invented by J Welles Wilder).
This ensures that we are buying only the strongest trending stocks and this ranking is defined using the 'PositionScore' formula in Amibroker.
Here’s a good example of the kind of trade setup we are looking for in Tyson Foods Inc (TSN), a consumer goods company that belongs to the S&P 1500 index.
You can see that the 10-week moving average crosses the 18-week moving average on the week of 16th October 2015 giving us a buy signal (green arrow). 10-week average turnover (shown in the middle panel) is well above $250,000, fulfilling our liquidity requirements and RSI(14) (bottom panel) reads 65.8 on the previous bar. At this time, the S&P 500 was also in an uptrend with it's 50-week MA sloping upwards.
We therefore enter our long trade at the closing price of $44.36 with 12.5% of our available capital. Note again that the averages are calculated and shown using the open price not the close price.
You can see that we exit the trade later on the week of 17th June 2016 (red arrow) when the two moving averages cross back over. Our exit is made on the closing price of $60.41 giving us a healthy profit of 36.13% after costs.
I’m now going to test this trading system on the S&P 1500 universe using Amibroker and a hypothetical starting capital of $100,000.
Our data includes historical tickers so there shouldn’t be any survivorship-bias. This means our results won’t be influenced by the exclusion of delisted or merged stocks because we are including those in our database. The database is also set up to include dividends and other corporate actions which could otherwise skew our results.
For our simulation, we are going to use trading costs of $0.01 per share to simulate commissions and slippage and we will avoid lookahead bias by trading on the weekly close and not the open.
As you will see from the following results and equity curve, running this simple trend following system on the S&P 1500 universe between 1/1/2000 and 1/1/2015 returned 12.80% annually with a maximum drawdown of -25.36%.
Our initial capital has grown to $609,806 and we recorded a win rate of 61%.
Annual Return: 12.80%
Risk Adjusted Return: 17.26%
Maximum Drawdown: -25.36%
Average Bars Held: 90.22
Win Rate: 60.91%
Profit Factor: 2.59
This compares to a buy and hold annual return of 4.26% with a drawdown of 55% on the SPY ETF.
Moving the dates forward we can now test the system on some out-of-sample data. This is data that is left out of the test environment so that we can better validate the system returns at a later point.
You will see that running the system between 1/1/2015 and 1/1/2017 we get an annualised returned of 12.74% with a maximum drawdown of -10.02% and a win rate of 62.16%.
Annual Return: 12.74%
Risk Adjusted Return: 14.87%
Maximum Drawdown: -10.02%
Average Bars Held: 74.76
Win Rate: 62.16%
Profit Factor: 2.48
This compares to a buy and hold annual return on the SPY ETF of 6.52% with a drawdown of -13.02%.
Overall, these are pretty strong results for a system of this kind. We have beaten buy and hold and our annualised return has remained above 12% in our out-of-sample. We have also achieved a small drawdown and high win rate.
It should be noted that I first came up with this trading strategy in 2014 so these out-of-sample results can be thought of as true out-of-sample results. In other words, they are not simply a process of moving the test forward, they are results that occurred after the system was created. This lends more credibility to the strategy even if it still cannot guarantee future success.
What is most encouraging is that we have been able to navigate the painful bear markets of 2000-2002 and 2008 without enduring too much pain.
Conclusions & Observations
Overall, this simple trend following system shows some promise and we were able to beat the buy and hold benchmark of the S&P 500 ETF 'SPY'.
I created this system some time ago now but it still manages to perform fairly well and it picks out some nice winning trends in stocks.
The ranking mechanism helps us enter the strongest tickers and the market timing filter keeps us out the market when stocks are in decline.
Crucially, by calculating our signals early and entering our positions on the close we are able to move faster than other trend followers who wait for the next bar open.
A potential drawback of this system comes from the market timing filter itself and the use of static parameters. There is a risk that a sharp sell-off in the market could lead to the system being whipsawed. Increased market efficiency/difficult market conditions can put pressure on a system like this because of it's low frequency.
It's for this reason that the system is best suited to markets where there are good probabilities of further upward price movement. The system has proven itself to be very effective at profiting from such trends.
Even so, you will want to test the system for yourself on paper and you may want to experiment with different settings and parameters. You may want to optimise the system on a regular basis, stress test the system further and get comfortable with how it works.
If you have Amibroker, you can download the code here. Note that the file has been provided in zip format for security reasons.
Some of you may be wondering whether such a simple system as described here is worth pursuing.
Perhaps you were expecting me to show you a system that returns 30%, 50%, or even 100% per year?
It's worth remembering that this system has been run on a lot of data and has proven to be a strong performer in trending markets. In 2013, for example, it produced a 56% return. Not bad at all.
Unfortunately, my experience is that medium to long-term systems like this one are rarely able to produce annualised returns much better than 12%-16% per annum over the very long term. US markets are just too developed and efficient.
I have found that trend following systems that promise much more than this range our usually over-optimised on the historical data and therefore have little chance of reproducing those gains in future years.
Fortunately, however, there are ways in which we can enhance our returns.
The first is to look at making improvements to the system itself.
The second way is to recognise the strengths and weaknesses of this system and combine it with other strategies to improve overall performance.
By including shorter-term, less correlated strategies it is possible to greatly enhance our overall returns without taking on additional risk.
This simple system that I have shared with you today is in fact very similar to one of the six systems described in the course Hedge Fund Trading Systems Part One which is part of Marwood Research.
Our program Marwood Research now consists of 9 premium courses and more than 15 complete trading strategies that investigate a number of different themes.
The strategies are a mix of medium-term, long-term and short-term models which are perfectly suited for combination as part of an overall portfolio.
You can investigate more of our courses and trading strategies on this website. Use the coupon code 'TRADER' to get 15% off at checkout.
CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE, SUPPORT AND TEXTS. OUR COURSE(S), PRODUCTS AND SERVICES SHOULD BE USED AS LEARNING AIDS ONLY AND SHOULD NOT BE USED TO INVEST REAL MONEY. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS SHOULD BE YOUR OWN. See full Risk Warning.