Sometimes you may have what you think is a winning trading strategy only for it to fail after a couple of trades. The fact is that not every strategy works. To figure out how effective your strategy is likely to be in the markets, you need to do some backtesting.
To backtest a trading strategy follow these tips:
- Choose a forex pair or instrument to backtest your strategy on.
- Open a chart of the market and scroll back to a past period.
- Look for trade setups based on your strategy. Record the trade’s information such as entry and exit points, stop-loss and take-profit levels, and the trade result.
- If there is no trade setup, move the chart forward in time until you find one.
- Repeat steps 3 and 4 until you have gone over the entire time period you are backtesting.
Strategy backtesting is a crucial element of a good trading system. Since it is a relatively good indicator of whether you have an edge in the market, it gives you confidence in your strategy. Before we have a closer look at how to backtest a trading strategy, let’s start by answering a crucial question.
Table of Contents
What is Backtesting in Forex?
In forex, backtesting is when you apply historical currency pair price data to your strategy to evaluate and gauge the effectiveness of the strategy. The assumption behind backtesting is that what worked in the past can also work well in the future. This means that if a strategy is profitable based on past market conditions, there’s a chance that it will be effective when applied to current market data.
Before you can backtest any strategy, you need to have a good trading plan in place. Backtesting without any rules guiding your trading decisions will likely give you inaccurate results and ruin the purpose of testing.
Some of the important elements to have in your plan include when you will enter and exit a trade, how much you’re willing to risk with each trade, the time frame you are trading, and where you will set your stop-loss and take-profit orders. Once you have a trading plan in place, you can backtest your strategy.
What are the benefits of performing a backtest for your trading strategy?
Strategic insight is probably the biggest benefit of trading strategy backtesting. When you test a strategy’s profitability potential over a long period, it’s easier to determine how robust that strategy is. This helps build your confidence in the trading strategy.
Trading strategy backtesting has other benefits as well.
- Opportunity to optimize a strategy. Testing can help you see where your strategy needs improvement. This will allow you to optimize the individual elements of the strategy.
- Developing analytical skills. Backtesting can help you practice spotting trading opportunities. Being able to recognize opportunities and recurring patterns is a good way to develop your trade analysis skills.
- Use as a research tool. You can use backtesting to check how a given strategy will work under different market conditions. For example, you can see how your strategy works in a trending market as opposed to a range-bound market.
- Time-saving capabilities. By backtesting, you can check the potential profitability of a strategy without having to test in real-time. This limits the time it takes to identify the effectiveness of a strategy and saves you a lot of time.
These benefits will give you an advantage in the market, but there is more than one way to backtest a strategy. You need to decide on a method that works best for you before you start any testing.
What is the best way to backtest trading strategies?
Trading strategy backtesting can be broadly categorized into two methods – manual backtesting and automated backtesting.
Manual backtesting is a method by which you manually scroll the charts to find trades that fit into your strategy according to the trading rules outlined in your trading plan. With manual testing, you have to manually scroll through a chart bar by bar, looking for potential trade setups. This can be arduous and you are susceptible to making errors.
Although manual backtesting may not seem like the most exciting way to test your strategy, it is a good way to get a feel of how well the strategy performs in various market conditions and where improvements are needed.
Automated backtesting is when you use a program that automatically enters and exits trades according to your strategy. It involves using tools such as the MT4 Strategy Tester to simplify the testing process.
You can create the automated backtesting program yourself, but this can be time-consuming, especially if you’re not a programmer. Another option is to use free already-made programs, but in most cases, the free programs don’t offer as many features as the premium versions. The paid versions can be expensive, especially if you are a newbie trader.
Manual backtesting gives you invaluable trading experience by allowing you to familiarize yourself with the strategy. On the other hand, automated backtesting may not add much to your experience since the program automatically trades for you. You also have to remember that not all trading strategies can be properly translated into an automated system.
Both backtesting methods have advantages and drawbacks. The best method for you will depend on your trading needs. Using both methods simultaneously will likely make backtesting difficult and even ineffective. It’s prudent to choose one of these testing methods and become good at it. You can always switch to the other method later if you want.
How to Backtest a Trading Strategy Manually in MetaTrader 4?
Manual backtesting is more common among traders compared to automated backtesting. MetaTrader 4 (MT4) is one of the popular platforms for manual backtesting.
What to do before manual MT4 backtesting
Before you jump right into backtesting your strategy in MetaTrader 4, you need to ensure that you have enough historical data. To get data for longer periods:
Select Options under the Tools menu in the top toolbar:
Select the charts tab. This will show you the maximum bars allowed in the charts’ history. Specify the maximum number of bars you want in history:
Note: MT4 doesn’t offer full market data for every instrument. You can manually select the market and time frame you want more historical data for. To do this:
Go to the Tools menu and choose History Center:
This will bring up the currency pairs and other markets you have available. Select the currency pair and time frame you want then select Import to import the data into the system.
Ensuring that you have sufficient data will give you a proper foundation for backtesting your strategy.
How to manually backtest a trading strategy in MT4
To backtest your strategy:
Step 1: Open the chart of the forex pair on which you want to backtest your strategy.
Step 2: Scroll back to a past period. You can scroll back by dragging your mouse or using the ← arrow key on your keyboard.
Note: Make sure the auto-scroll feature is turned off otherwise the chart will keep on jumping forward to the latest market prices. You can disable the feature directly in the charts toolbar:
You can also go to the Charts menu in the top toolbar and disable auto-scroll.
Step 3: Once you have scrolled back far enough in your chart history, you can start manually backtesting by tapping the F12. This moves the chart forward one candlestick at a time. You can move the chart backward by one candlestick at a time by holding Shift+F12.
Step 4: Look for possible trade setups. If you spot one that meets the requirements of the strategy you are testing, you will need to take note of the trade’s information.
You can do this using a simple Excel spreadsheet. Examples of information you can note include your entry point, risk/reward ratio, stop-loss, take-profit, and the trade result.
Step 5: If you can’t identify a setup, keep moving the chart forward bar by bar.
Step 6: Repeat steps 4 and 5.
The pros and cons of manually backtesting in MT4
The two biggest benefits of manually backtesting in MT4 are that it’s free and you don’t need any coding knowledge.
MT4 manual backtesting also has some downsides.
- The platform offers limited historical data.
- The whole process can be tedious and it’s easy to make mistakes when you’re tracking your results.
- It’s hard to backtest your strategy when your trading considers multiple time frames.
TradingView, a free cloud-based charting platform, is another good option for manual strategy backtesting.
How to Backtest a Trading Strategy Manually in TradingView?
TradingView requires no complex setups to start backtesting manually. To backtest a strategy you simply got to the TradingView site and follow these steps:
Step 1: Choose the market on which you want to backtest your strategy and open the chart.
Step 2: Scroll back to a past period. You can scroll back by dragging your mouse, using the < key at the bottom of the chart, or the ← arrow key on your keyboard.
Step 3: You can start backtesting by moving the chart forward using the > arrow key at the bottom of the chart.
From here you identify any trade setups and if there are any, you record the trades’ information. If there are none, you keep moving forward and then repeat the process similar to what you do when backtesting in MT4.
TradingView also has a very useful tool for backtesting – the Bar Replay feature. This feature will playback the charts from a certain point in the past so you don’t have to be manually moving forward. To use the replay feature:
After opening the chart for the market you want to backtest your strategy on, turn on Bar Replay using the icon on the top toolbar:
A new toolbar will appear on the chart. Click on the Jump To… icon:
A red vertical line that marks where the replay begins will appear. Scroll back to the point where you want the testing to start:
Select the play button to start the replay. You can also adjust the speed of the playback using the bar replay toolbar.
Once the playback starts, you can look out for trade setups. You can even pause the playback using the pause button.
The pros and cons of manually backtesting in TradingView
Using TradingView for manual backtesting is free and requires no coding. The platform provides many trading indicators you can use in your strategy and it’s also web-based. You don’t have to download any software, an internet connection is all you need to access TradingView.
Nonetheless, there are some cons to using TradingView.
- Some chart options have limited historical data.
- When using the playback feature, you cannot use indicators that have a security function.
- Similar to MT4 manual backtesting, the process can be laborious and you can easily make errors when tracking your results.
Tools to make Backtesting easier
Manual backtesting can be quite tedious. You can use some tools to overcome some of the limitations of manual testing. Forex Tester and Simple Forex Tester are two such tools.
Using Forex Tester
Forex Tester is a popular strategy backtesting tool for MT4. The tool requires no coding and it even provides traders with some pre-formed strategies. With Forex Tester, you can also apply multiple time frames and the tool automatically tracks your trading results whenever a trade is closed.
To use Forex Tester:
Download the software and complete the installation process by following the prompts.
Once you have installed the software open the program.
To backtest a strategy, create a new project by selecting the New Project button in the top toolbar:
A window for creating a new project will pop up:
Give your project a name, specify an initial deposit amount, and click “Next”.
Select symbols of the market you want to backtest your strategy on and define the testing period. You can also choose the testing quality. Click Next:
Complete defining your test parameters and click on Create. The test will start immediately:
You can pause testing by clicking the pause button, and resume testing by clicking on the button again:
You can also stop testing by using the Stop Test button. To resume testing, you simply click the Start Test button:
To adjust the speed of testing, adjust the speed slider:
Forex Tester offers many customization options. For instance, you can test custom time periods using the Data Center button and you can change time frames using the Time frame drop-down menu:
Using Simple Forex Tester
Simple Forex Tester also allows for MT4 backtesting and it offers many features. For example, in addition to allowing multiple trades and test windows, the tool also syncs with real-time live accounts and gives you access to comprehensive backtesting results.
Before installing the Simple Forex Trader software you have to ensure that it will work properly in MT4. To do this you have to open the MT4 platform.
Go to the Tools menu and select Options. The options window will pop up:
Under the Expert Advisors tab, make sure that “Allow DLL imports” is checked. Click OK:
Once you complete this step, you can download the Simple Forex Tester and follow the installation wizard.
Simple Forex Trader works with the MT4 Strategy Tester, therefore you first need to enable Strategy Tester before you can backtest your strategy. To enable the Strategy Tester, go to the View menu from the top toolbar in MT4 and select the Strategy Tester feature.
Alternatively, you can simply press CTRL + R on your keyboard.
When the Strategy Tester is enabled, it will appear at the bottom part of the window.
This is where the backtesting takes place.
To use Simple Forex Tester:
In the Tester window under the Strategy Tester panel, select Simple Forex Tester from the drop-down menu next to Expert Advisors.
Set the parameters for testing. For example, the symbol of the currency pair you want to test your strategy on, model, date range, and trading time frame. Make sure Use Date is checked so you can define a date range. Also, make sure that the Optimization box is not checked:
Click Start. A startup prompt ‘Program Startup OK! Click “OK” to connect to MetaTrader 4 now’ will pop up. Click OK:
Once you click OK, Simple Forex Tester will start testing your strategy. When you are done testing you click on Stop. You can get a detailed report of your test under the Report tab.
To save the report, right-click while in the Report tab and select the Save as Report option.
The report will be saved as a web page in HTML format.
The following are some questions related to backtesting a trading strategy.
How do you backtest an EA (Expert Advisor)?
Since MT4 is a popular platform among traders, we’ll take a look at how to backtest an EA in MT4 using the MT4 Strategy Tester.
1-Select your EA from the Expert Advisor options.
2-Set the parameters:
- Define the currency pair and time frame you want to backtest using the symbol and period parameters.
- Select the spread according to your broker fees.
- Make sure the Use date box is checked and specify the time period you want to test.
- Make sure the Optimization box is not checked.
- Choose the model value out of the three possible options.
3-Click on the Start button to start the test. Your results should be available in the Results or Graph tabs after a couple of seconds or minutes. The time it takes before you can see the results depends on the length of your testing period and how fast your processor is.
Note: Remember to load the appropriate historical data before backtesting to avoid mismatched data errors.
How do you backtest an indicator?
The process for backtesting an indicator is similar to that of backtesting an EA
1-Select Indicator from the drop-down menu in the Tester window:
2-Choose the indicator you want to backtest your strategy on from the drop-down menu next to the indicator menu:
3-Enter all the necessary parameters (e.g. symbol, period, model, and spread).
4-Start the backtest.
How far back should you backtest a trading strategy?
There is no one-size-fits-all approach to how far back you should backtest your strategy. In general, it’s a good idea to backtest your strategy in a way that best resembles your normal trading environment.
For instance, if you trade on a short time scale, your backtesting will differ from that of someone who holds their position for a longer time. If you’re a long-term trader, backtesting a short period can mean that you only catch one type of market (e.g. a trending market) and miss the bigger picture.
The common rule is to increase your backtesting time the longer your holding period. Conversely, if you have shorter holding periods, you will probably still do fine with less backtesting time.
You may also want to backtest your strategy on multiple market conditions and time frames to see how the strategy performs in various environments. For example, you can choose to test your strategy in both active and slow markets.
What is the difference between Backtesting vs Forward Testing?
Backtesting your trading strategy may show you that the strategy would have worked in the past. But the forex market is dynamic and there is no guarantee that a strategy that was profitable in the past will remain profitable in the future. In other words, past results are not a foolproof indication of future performance. It’s useful to have another test that helps determine the soundness of a strategy. This is where forward testing comes in.
Forward testing is similar to backtesting. The biggest difference is that forward testing analyzes real-time data instead of historical data. The general idea is that once you have a trading strategy that’s profitable in backtesting, you move on to forward test it. With forward testing, you simulate actual trading and test your strategy on a live market.
Although you can never be certain that your strategy will work, when both your backtesting and forward testing show that your strategy is effective, there is a higher chance of the strategy performing well when it comes to actual trading.
Backtesting your trading strategy can help you eliminate strategies that just don’t work. However, despite the usefulness of backtesting in determining the viability of your strategy, remember that any conclusions you make are speculative since you can’t predict market conditions with absolute confidence. It’s a good idea to keep on testing your strategy and optimizing it for different market conditions and trading scenarios.