How to build and backtest a robust forex trading system
By definition, a forex trading system is robust if it remains effective under different market conditions. Robustness is what all forex trading systems should strive for. Clearly, if a profitable forex trading system can operate in various times, the profit will rise with the number of trades. Moreover, a robust trading system is to some extent immune to a sudden change in the market, meaning that risk is greatly reduced. In this article I will describe how to backtest a trading system for robustness. I will also clarify the most dangerous misunderstandings about robust trading systems and backtesting.
A backtest consists of a series of simulated trades using historical data. After a backtest, you should have a clear idea how the tested forex system would perform in the past. I never use a trading system without backtesting and I do not know any successful trader who does. On the other hand, the past performance does not necessarily predict the future performance. Backtesting is a powerful tool only if it is used smartly.
How to run a backtest? First, you need some backtesting software. There are several paid backtesting programs and the quality of their algorithms is presumably higher. But even a free backtesting program should not have any problem identifying a truly robust trading strategy. The worst what can happen is that you slightly underestimate profitability of a forex trading system because of what we call in statistics the measurement error.
The most popular backtesting program in the retail forex market is MetaTrader 4 (MT4). You can use MT4 for free. Just open a demo account with any of the forex brokers supporting MT4. The MetaTrader’s syntax is easy to learn, especially if you have experience with any other programming language. Great tutorials and a helpful community of MetaTrader fans can be found at www.mql4.com. Historical forex data for MetaTrader 4 can be downloaded for free from Alpari. An important advantage is that you can use MT4 also for automated forex trading after you are satisfied with your forex trading system.
Alternatively, you can use a spreadsheet in Open Office, MS Excel, or any similar software. Historical forex and stocks data in the spreadsheet format can be found here. But I recommend backtesitng in Excel only for simple strategies or for trading systems that use longer time frames (days or weeks). Otherwise, your task can get complicated and time-consuming.
What you are looking for in backtesting results is the win/loss ratio, which is a proportion of winning and losing trades. Another important measure is the average profit (and average loss). Risk is estimated by a drawdown, that is the largest percentual loss measured from a historical peak.
In addition to these straightforward quantitative measures, you should also examine simulated trades more intuitively. Let say, an otherwise profitable forex trading system also produced a strike of eight unsuccessful trades. When you look more closely at these trades, what market conditions were prevailing at that time? Perhaps your forex system performs badly in a ranging market. Perhaps it cannot achieve any profit if volatility is too low. Perhaps it should not trade on Monday. If you find a variable that systematically predicts losing trades, you can avoid the identified dangerous periods in the future real trading. By specifying conditions under which a trading system maximizes profit, you are doing what is called optimization.
Whenever you optimize a forex trading system using the values identified by backtesting, ask yourself two questions: First, could you predict the same result from the trading strategy itself, without looking at the data? For example, if your forex trading system follows a trend, it obviously will not perform so well in a ranging market. The system behaves as it should. But if your universal trend-following system is profitable only in a bullish market and you have no idea why it loses money in a bearish market, something is wrong. Second, do you have any strong theoretical reason why a variable should be set to a particular value and not some other value? For example, a forex trading system based on morning breakouts will naturally work in the morning and there is no reason to expect the same performance at night. It is all right. However, if you find out that for some unknown reason trades on Monday and Wednesday are profitable (on average), but Tuesdays and Thursdays produce only losers, your trading system is probably not robust. If you optimize parameters that you do not understand, you are not improving your forex system. You are overoptimizing or curve fitting.
A serious but frequent error is to overoptimize a trading system. If you have an unprofitable forex trading system, it is usually easy to find some very specific conditions, under which it would turn profit in the past. But, if these conditions are not theoretically grounded, they can be (and usually are) attributed to chance. There are techniques to fit a series of data points almost perfectly. But such curve-fitting exercise will reveal nothing about the future. You can optimize a forex trading system to produce a simulated annual profit of 1000% in the historical data only to find out that it does not work at all in the present. A robust forex strategy should be profitable under various market conditions, not only on Mondays and Wednesdays.
When you are backtesting a forex trading system, try to vary your main variables. Let us say that you enter a trade when the stochastic crosses some value. The backtesting results show that the strategy would be highly profitable if you take profit (TP) at the distance of 30 pips, slightly less profitable for TP=25 and TP=35, and still somewhat profitable for TP=20 and TP=40. The results like this indicate that your forex system is robust. If your forex system appears to be profitable only for TP=30 and not for TP=29 or TP=31, this illusory profit is nothing else than artifact of the used historical data. The most likely explanation is that there were two or more trades with TP=30 that produced profit by pure chance, though the forex system itself is a loser. There is no reason to believe that such a strategy will be profitable in the future. If a backtest shows a profit for few distant values, such as TP=17 and TP=31, but not for any other values, the strategy is not robust either. If a backtest on Alpari’s data shows a profit, but a backtest on IBFX’s data from the same period does not, the forex trading system is probably not robust. I could continue, but I am sure you have got the point.
On the other hand, it is not wise to check robustness by changing time frames or instruments. So, if a forex system uses 1-hour charts, it is not necessarily applicable to 1 day charts. If a forex strategy works with USD/JPY, it might not work so well with EUR/GBP. This is not the lack of robustness. Different markets are characterized by different patterns. Similarly, your robustness check should not go beyond what are theoretically grounded values of the variables. To give you an example, if you believe that it is profitable to buy JPY in March because carry trade unwinding tends to happen in March, there is no reason why you should test robustness by buying the Yen in April. Always stick with the theoretical basis of the trading system.













November 1st, 2008 at 3:46 pm
Dear Sir ,
I am looking for some body to build a trading system for me by using the MACD Histogram so i can use it on MT4 Platform .I just want an arrow and an audio when ever the histogram crosses the center line either up or down .
Regards ,
Daniel .
November 14th, 2008 at 4:08 am
Hi, nice information.IT gives very good information.
November 14th, 2008 at 7:20 am
Two thumps for you, excellent post here. You seems to be an expert forex trader. The way you have represented the information is absolutely fine and important for every genuine forex trader. Thanks for this excellent work.
November 15th, 2008 at 4:34 am
I am surprised that no-one has written a review on Bloomberg. If you are serious about making money trading stock, bonds, commodities or Forex Bloomberg is a must. Bloomberg.com has great information on their site and if you combine that with the Wall Street Journal, Barron’s, and London Financial Times you are off to a good start but you need the tool that all the financial houses use. YOU NEED THE BLOOMBERG TERMINAL.
The service will cost you $1,500.00 a month but the information is invaluable.
I believe they have over a quarter million subscribers and my sales executive will get on a plane and do whatever it takes. The service and support is second to none and I am sure that you will agree that the subscription pays for it’s self many times over each month. The BLOOMBERG TERMINAL is not a cost of doing business it is an investment. If you wish a referral I will be glad to help. You will make informed decisions.
Best Wishes,
Alex Findlay
PS: How Many $1,500.00 mistakes have you made? Warren Buffet said learn from the mistakes of others not your own. I have told you what I think, but the decision is yours.
November 15th, 2008 at 11:57 am
Alex, this is an excellent idea. I actually use Bloomberg, but only to get quantitative data. I do not need their other services. I am lucky to have a Bloomberg terminal in my workplace. But if I decide to quit and trade forex full-time, I am not sure if I want to pay so much for the Bloomberg terminal, given how little information I actually use. I also think the whole idea of a hardware solution (a terminal) is a bit silly. I would love to have the same full access to data from my home computer. Hello Bloomberg, wake up, it is the 21st century… Despite my criticism, it is still a great service (actually the best I have ever used). And Michael Bloomberg himself is a pretty good mayor.
November 22nd, 2008 at 6:33 am
Good information, i was quite confused on building and back testing a robust forex trading. you have given plenty of information on this subject. and sure it is going to help me lot in forex trading programs. thanks again.
November 27th, 2008 at 5:02 am
you have done a great job because many people are doing forex trading but they don’t know proper forex trading systems to achieve profit. But after referring your blog they will really get excellent forex trading systems they want.
December 13th, 2008 at 5:02 pm
Hi,
Very informative stuff. i would really appreciate if you could show me how to setup a trading system which automatically reenters the selling or buying price i set on its own each time it closes the trade?
Kind regards