Before we define a mechanical trading system it's best to understand fully the concept of a trading system:
What is a Trading System?
Trading systems are defined by a common set of rules which encapsulate all buy and sell (entry and exit) trading decisions. All trades executed following these common rules belong to the trading system.
This is easy to follow with the help of an example.
John has a share portfolio which consists of some Blue Chip shares and some smaller Speculative Shares. Even with this classification John has two distinct Trading Systems,“Blue Chip Shares” and “Speculative Shares”. Imagine the flexibility and analysis capabilities obtained by managing each trading system independent of the other!
In the example above, John could split his share portfolio into as many trading systems as he likes. Remember, you can create as many trading systems as you like, defined by an unlimited number of rules.
For example, John uses a rule that he will buy shares in all companies which have a PE ratio below 10 and volume turnover of more than $15,000,000 per day. John creates a trading system called “LowPEHighTurnover” to manage all his investments.
All future trades that John makes based upon his rules will belong to the "LowPEHighTurnover" Trading System. To extend this concept even further you can get creative and set up numerous trading systems which are independent of each another.
The benefit of creating trading systems is the high level of control and analysis capabilities which it provides. Having numerous Trading Systems is only beneficial when you have the right tools to help you with the analysis process.
What is a Mechanical Trading System?
A more advanced concept of trading systems is that of mechanical trading systems. Mechanical trading systems are designed to be totally mechanical in nature. A mechanical trading system executed correctly will exclude the undue influences of emotion, which can hinder the performance of many traders.
Human emotion is one of the most complex and hard to control areas of trading. No trader or investor has been able to conquer the market without first controlling their emotions.
Mechanical trading systems are defined by a distinct set of rules which instruct the trader what should be done and when to do it (entry timing and exit timing). It provides a signal when the trader should enter a trade and when the trader should exit a trade.
As the rules of a mechanical trading system are clearly defined, we can backtest the mechanical trading system over historical data. Backtesting is important to provide confidence that your mechanical trading system will be profitable. Backtesting is required before you undertake to commit any capital to a mechanical trading system. The results obtained from backtesting will provide an indication of the system's profitability, sustainability and highlight the characteristics of the system to illustrate how it will behave in a real life trading situation.
When performed correctly, backtesing is the closest we can get to determining the sustainability of a mechanical trading system without actually risking any money. Backtesting provides an easy way to gain confidence regarding the profitability of the system before you make the decision to commit your hard earned money to trading it.
Mechanical trading systems can be defined as a method of generating trading signals and quantifying risk independent of a trader's discretion. Although the advantages of utilising a mechanical trading system are many, most market participants agree that their greatest benefit is the tempering of destructive emotions, considered the enemy of all successful traders, from the decision making process.
Types of Mechanical Trading Systems
Mechanical trading systems which primarily use price data (high, open, low, close and volume) to derive trading signals can be classed as being either trend following or reversal based.
Trend following and reversal based trading systems have distinctly different characteristics.
Their characteristics will influence which type of trading system you decide to trade or design. The frequency and duration of trades signaled by either system are amongst the common differences between these two trading system types.
Trend following trading systems:
Trend following trading systems try to capitalise upon an established trend in the price of the security. For this reason, trend following systems tend to be traded over a longer time horizon than a reversal system.
When compared directly to a reversal system, the duration of the trades in a trend following system are distinctly longer and the number of trades taken by the system is less.
Trend following systems are most suited to be traded for long term gains as the capital and time requirement for this type of system is less than a reversal system.
Reversal systems:
Reversal systems on the other hand try to identify a change in the direction of a security and capitalise upon this change in direction.
Reversal systems anticipate a change in direction of a security and as a result will signal more trades on average than a trend following system. The increased number of trades is compensated by a shorter trade duration.
Reversal systems are most suited to traders who wish to be more active in the market. The potential for short term gains is high however reversal systems require more discipline and time to trade correctly.
Backtesting your trading system
What is going to give you the confidence to start trading your hard earned money on your trading system idea?
Any wise investor will do as much testing as possible before starting to trade a system with real money.The best option is to backtest the idea over historical data to determine how well it would have performed over that set of data.
Interpreting these results will provide you with sufficient information to assess the potential of the trading system.
When backtesting, your aim should be to replicate real life as close as possible. This means a proper backtest will need to effectively go back in time and start trading your mechanical trading system moving forward to the end of the data set.
So, how do we go about doing this?
In today's technological world, you can use the power of computers to complete the backtesting for you, to do this you will need:
1. A computer.
2. Backtesting software.
3. Historical data.
The only other alternative is to perform a manual backtest. This is not only time consuming but very hard to replicate and test variations of your mechanical system.
In other words, you should automate the backtesting process.
So long as your mechanical trading system works with just price data (open, high, low, close, volume) you will be able to utilise backtesting software to perform the test.
It will be no use backtesting, if your historical data does not enable you to test your idea. For example, you create a mechanical trading system with the following buy rule:
Purchase the share when the 10 day moving average of the close crosses above the 50 day moving average of the close.
The rule above can be tested quite comfortably over historical data which contains only price data. If, on the other hand your buy signal rule was a little more complex as detailed below:
Purchase the share when the 10 day moving average of the close crosses above the 50 day moving average of the close and the price to earnings ratio was 80% or lower than its value 4 months prior.
This rule is very complex as it introduces data which is not often supplied or maintained in a database of price information.
To successfully backtest this would involve obtaining historical data of the close as well as the price to earnings ratio (PE ratio). Obtaining historical information on a group of equities would normally consist of only the open, high, low, close and volume for each period.
Because of this limitation many mechanical trading systems are designed around purely technical indicators and rules based around only the open, high, low, close and volume information (price information).
Any mechanical trading system designed around fundamental data is really beyond the scope of retail investors due to the lack of historical data available to conduct a complete backtest.
With this in mind, remember that backtesting is not compulsory. You can start trading your own mechanical trading system without completing backtesting, it is a high risk strategy which is not advised.
Read on to learn more about the backtesting process.
With advances in technology, a wide range of trading system backtesting software is available. The benefits obtained from backtesting software cannot be underestimated. It will save you time and provide an endless opportunity to fine tune and test variations of your ideas.
A small outlay in capital to purchase good backtesting software will potentially save you thousands in the market if you have not backtested your ideas properly, it's a very wise investment if you are considering designing a mechanical trading system.
This is a quick guide to highlight some of the items which you should keep in mind when searching for backtesting software.
What backtesting methodology does it employ?
Sounds like a really complicated question, but it's not. Always remember that backtesting software should represent real life as closely as possible when it performs the test.
This way, you will have more confidence in the results. Never forget it will be your hard earned money on the line when you start trading for real!
“Real life” simply means that as we trade in our everyday lives we can make trades as much as our capital will allow.
For example, suppose you have two backtesting software applications, one of them performed the backtest by going back in time and starting from the start of the data moving forward one day at a time. The other started from today and worked its way backwards.
Which one of these represents real life the closest? Of course the first one is the obvious choice.
You should always ask the following questions about the backtesting methodology which the software employs:
1. Does the test move forward from the start of the data and step through each period of that data?
2. Does the backtest software monitor my money available for each trade and not trade if there is no money?
3. Does the software stop the test when I run out of money? In other terms does the test continue after you experienced negative equity. Remember in real life you cannot continue to trade if you have no money left.
Is the backtest software dependant upon any other software?
You need to find out if the backtesting software is dependent upon you owning another piece of software in order for it to run.
This is not necessarily a bad thing as the software may be utilising functionality from another piece of software which is superior in the industry. It is not necessarily a bad thing for the backtesting software to rely upon another piece of software, in fact, it may make the backtesting software better as the programmers and designers have had more time to concentrate on the backtesting functionality of their program with minimal time needed to be spent on the functions which the other software performs.
If you are required to own another piece of software you will be best advised to investigate that software application first.
What kind of data does it accept?
All backtesting software will require the use of data in order for it to perform its backtest.
Even when the data only consists of open, high, low, close and volume information, the software application may rely upon a certain format. Make sure the data you have or are wishing to obtain is fully compatible with the backtesting software.
Will it backtest leveraged instruments?
People will design and create mechanical trading systems for all types of instruments. The most common will be a normal share.
What if you designed a mechanical trading system for a leveraged instrument? You will need to backtest your idea using the correct leverage settings for the instrument.
If you think you will be in a position to design a trading system for leveraged instruments then you need to make sure the backtesting software caters for those instruments.
Is there a limit to the number of instruments that can be backtested?
If you design a trading system for a universe of 1,000 stocks you will need to make sure the backtesting software can cater for the large number of stocks (items) required for the backtest.
We have known some backtesting software to be limited to a maximum number of items, this is an area for concern as it puts a caveat on the backtest results and on the design of the mechanical trading system.
Make sure you can run the backtest on a limitless number of items.
Backtest results, what should I expect?
Once you have performed a backtest you will begin to analyse the results. The results you obtain from the backtesting software should be comprehensive enough to give you a clear indication of the potential of your system.
Expect nothing more than an absolute abundance of statistics and graphs to illustrate the results of your trading system.
When it comes to trading system performance data, the more the better. The more statistics and graphs you can analyse will enable you to tune and tweak you trading system enabling you to create a more powerful system which you can have confidence trading in real life.
In addition to backtesting results you will need to have the same level of detail and sophistication when you start trading your system in real life, this is where Stator - Advanced Finance Management takes over.
Remember, the more statistics the better.
Make sure the backtest recognises your account capital as it moves forward in time.
In real life you start trading with a set amount of money (capital).
If you trade this amount of capital and run out of money after one year, you can't continue. It's a simple equation, running out of money means you can't continue trading.
Make sure the backtest follows this same real life scenario, as it will be no use having ten years worth of results when your account capital reached negative figures after only one year.
In real life this event would have forced you to stop trading.
Make sure the backtest allows the use of money management.
Make sure you can play around with various money management (position sizing) models when performing the backtest.
Money management can dramatically change the results of any trading system. Having the ability to adjust your position size based upon risk is a very powerful concept which can dramatically improve the results of any trading system.
We highly recommend being able to adjust position sizing when performing a backtest.
For more information about various money management models and position sizing click here.
Understand what language the backtesting software speaks.
Computers do only what humans instruct them to do.
When you design a trading system, you want to have no limitations on the ideas which you can test. Any good backtesting software will be controlled by some programming language, make sure this language is as flexible as possible.
You will find some backtesting software uses established programming languages and others have their own programming language, either way make sure this language offers a wide range of options and flexibility.
The more flexible the programming language, the more creative your trading system can be.
Some points to bear in mind when backtesting
We previously made mention that backtesting should be designed to mimic real life as close as possible.
The following points are issues which you need to be aware of when performing any trading system backtest.
Ensure you have clean historical data.
When preparing to perform a backtest you need to ensure you have clean data. Make sure the data is correct (adjusted for splits etc) and contains the exact universe of stocks you wish to backtest.
For example, if you have designed a mechanical trading system which you wish to backtest on the Australian S&P ASX 200, your data will have to comprise of stocks which make up the S&P ASX 200 index.
Good, clean data is crucial to a proper backtest. Make sure you obtain good quality data for your backtest.
Setup is everything.
These days, running a backtest simulation will not take long at all. Be careful however that you check all the settings before you run the backtest.
It's also advisable that when the backtest is complete you re-check the settings.
If the results are too good to be true then they probably are.
You won't be the first person to backtest various trading system ideas. Many beginners fall into the trap of running a backtest and getting carried away with results which are too good to be true.
Whenever you get results which just seem too good, take the time to check and re-check your code.
Make sure you have programmed the system to represent real life and some common areas to check may be:
1 . Your entry is looking into the future. (can't do this in real life)
2 . You enter a position on the open however part of your entry criteria is the close of this same day. (can't do this in real life)
3 . You use an indicator which uses future periods to determine its value (zig zag indicator is a perfect example)
The real motto with this tip is to check and re-check your code to validate that it's representative of real life.
Searching for the Holy Grail is pointless.
Sooner or later you will find yourself testing ideas in the hope of stumbling across that magic secret which will unlock the market and all its profits.
This won't be the case, you will never create a trading system which has a 100% success rate. Many have tried and many have failed.
The Holy Grail does not exist.
You should be looking for a good trading system with minimal draw-down (the maximum equity during the trading systems life) and a good reward risk ratio.
Many trading systems have more losing trades than they do winning and the system still makes money. A perfect example are trend-trading systems made famous by the Turtle Traders, this system only had ~40% winning trades.