Forex Backtesting: The A-Z Guide to Backtesting Your Strategy

This is a complete guide to forex backtesting in 2022.
In this new guide, you’ll learn:

  • How to set up a forex backtesting project
  • How to evaluate your performance
  • How to backtest on multiple timeframes
  • Lots more

Let’s get started.

Heads up!: We’re going to use an MT4 backtesting simulator called Soft4FX. There is a free version that you can use to follow this guide. However, if you purchase the full version through our link,, we get a small commission. This comes at no additional cost to you.

Forex Backtesting Basics

Maybe you’ve been working hard to make money as a trader, but haven’t been backtesting your strategies. This is a huge mistake; it just might be enough to prevent you from being profitable.

The ironic reality is that if you stop focusing so much on chasing pips and instead focus on flawlessly executing your strategy, you’ll start getting results. However, executing your strategy perfectly is extremely difficult if you don’t even know whether or not it works.

Backtesting in forex is the process of assessing your trading strategy by seeing how it would play out in the past.

forex backtesting

You do this by executing your strategy in a simulated market environment that uses historical market data. Because the past is already known, you don’t have to wait days or weeks until a trade finishes; you can just go ahead in time and see the outcome instantly.

This is pretty neat, and it’s where most of the benefits of forex backtesting are coming from.

Forex backtesting shows you the validity of your strategy and gives you the information you need to make it better. Even more importantly, it helps you understand your strategy and what you can expect from it.

The latter is crucial because no matter how awesome an analyst you become, you will never be able to anticipate the future with certainty. However, if you know what you can expect in the long run in terms of wins, losses, time commitment, etc., you can reduce uncertainty to a convenient degree.

Reduced uncertainty

This will boost your confidence and, eventually, you’ll be able to trade without fear and stress. It doesn’t happen overnight, but it does happen if you are perseverant.

Getting Ready for Backtesting

Before you can begin trading your strategy on past market data, you must do a few things to prepare yourself for backtesting.

The first step is to have a computer with Windows on it.

If you want to backtest on a Mac computer, consider installing Windows in a VirtualBox. It’s beyond the scope of this guide, but a quick Google search will help you out.

The second step is to download MetaTrader 4. You can do that here for free.

(You must download MT4 and not MT5.)

The third and last step is to download a forex backtesting software called Soft4FX.

Soft4FX is not a standalone software, but an expert advisor for MetaTrader 4. It has its own interface, but it relies on MetaTrader for key functionalities such as charting tools, sound effects, and other design elements.

The reason we use Soft4FX is that it’s a great alternative to expensive backtesting tools, namely Forex Tester. That said, you still have to pay $109 for the license. However, the demo version is just fine for following along with this guide, and you can decide on the purchase later.

Once you have downloaded the simulator file, place it into your MetaTrader’s data folder. (MQL4 -> Experts)

MT4 data folder location

Make sure you allow DLL imports in MT4, as this is necessary for proper functionality.

DLL Imports MT4

DLL stands for Dynamic-Link Library and it allows the developer to do things that wouldn’t be possible with the MT4 programming language.

For example, MetaTrader’s programming language (MQL) might not have certain functions that the developer needs; therefore, by using DLL, the developer can import these missing pieces from elsewhere.

Once you have Soft4FX in the MT4 data folder, you will need to restart the terminal. Then you’ll find it under the Expert Advisors tab inside the Navigator.

Soft4FX location

Double click to launch and a window will appear. You must navigate to the inputs section to enter your email and activation code. If you don’t have a license, you can leave these empty and start the program in demo mode.

Soft4FX activation

With that, you’re ready to customize your forex backtesting project.

Setting Up a Backtesting Project and Customizing the Parameters

Most backtesting projects start with some initial planning. This means setting up a paper trading account and deciding on the key parameters of the simulation.

Click on “New Simulation”.

New Simulation

You’ll be presented with a bunch of settings that will help you create the environment you need.

Backtesting parameters

In essence, there are three main sections:

  • Historical data
  • Main settings
  • Advanced settings

Let’s quickly talk about each.

Historical Data

This is the place where you can choose your data provider and currency pair.

Historical data settings

It’s important to note that the dropdown list includes only instruments for which you have available data. You can download data with a few clicks from the Soft4FX data center without leaving your MT4 terminal.

Soft4FX Data Center

Depending on your strategy (which timeframe are you using), download an appropriate data range; otherwise, your backtesting result won’t be meaningful. For example, we backtest on three years of market data using the daily chart.

It’s worth mentioning that you can backtest on only one pair at a time.

If you want to test your strategy on more currency pairs, you will have to run separate simulations for each pair. You can then summarize the results to see your overall performance.

Main Settings

To set the general parameters of your simulated trading account, you will need to adjust the main settings.

Main Settings

You can decide when to start the simulation and whether you want to automatically end it at a certain date or continue until the last data point.

You can also choose your account currency, although it’s almost entirely decorative, as you’re trading with paper money anyway. You can choose only between the two currencies you test. For example, if you’re testing EUR/USD, you can have EUR or USD as your currency.

Again, this isn’t very important, and we recommend that you measure your performance in percentage returns anyway.

Image description

Nevertheless, for the starting balance, it makes sense to use a balance that you could deposit in real cash. You want to imitate real-life conditions as closely as possible and your account size influences things like position sizing and risk management.

As the last setting, you can decide whether you want to allow rewinding. We initially disabled this option, but after hours of backtesting, we got tired and missed some great opportunities that we would certainly have recognized in a live trading situation.

So, if you can use it sensibly, we recommend that you allow rewinding, as it enables you to move back a few candles whenever you clicked too fast and ignored a trading opportunity. If you feel you’d get skewed results, leave it unticked.

Advanced Settings

Advanced settings is about fine-tuning some less fundamental aspects of the simulation.

Advanced settings

To begin, you can change the pip size and the size of one contract. You might need it for backtesting on different markets, but if you’re trading only forex, you can leave it on default.

What you might indeed want to change are the leverage and commission settings.

For both, we recommend sticking to the conditions your broker provides.

As a general guideline, most EU traders can access leverage of 1:30 for forex, while traders in the US have a slightly higher limit of 1:50. This might vary depending on what you trade and whether or not you’re a professional trader.

Spreads are typically variable unless you have some specific account type. For example, some brokers provide accounts with zero spreads and a fixed commission per lot traded.

Before starting the simulation, you have the option to set the initial history on the charts. This might come in handy if you want to plot support and resistance levels or do some preliminary analysis.

How to Backtest Your Forex Strategy

Once you set up everything, simply click on “Start Simulation”. You’ll immediately be taken to the “dashboard”, which looks like this:

Soft4FX dashboard

The different menus and options might look intimidating first, but don’t worry. If you continue reading this guide, you’ll quickly master the nuts and bolts of the platform.

Let’s start by opening the charts you need.

Click on “charts” and set the chart type and period.

Adding Charts to the backtesting project

You can also decide on the number of bars the chart can keep. Note that it’s not the same as the initial chart history, which you could set at the advanced settings before launching the simulation.

Added charts will appear at the top of the “chart selection” window and you have to manually open them.

opening charts

Feel free to change the colors and add any indicators you need. If you work with more charts, you might want to create a custom template so that you can apply it to other charts with a click.

Saving Custom Templates

Make sure the custom template is created on a chart other than what is opened for the simulation. Otherwise, if you create a custom template on a simulated chart, the Soft4FX toolkit at the top-right corner will be included in the template.

Once you finish setting up your charts, you can begin the market simulation. We typically like to proceed from bar to bar by clicking “Next Bar”, but you can set the speed of the market and let it move forward automatically.

Backtesting

Either way, move forward until you bump into a valid trade setup.

Trade set up

Then, depending on your strategy, place a market or a pending order.

You must set the details of the trade at the top left corner.

Placing an order

If you don’t use stop losses or take-profit orders, leave the boxes at the default 0. The lot size is obviously required, and it should represent 1% or 2% of your account size as defined by your trading plan.

For market orders, this is all you need. You can click buy or sell and the trade will be executed. For pending orders, however, you must also define the distance in pips.

pip distance

Only then can you place the appropriate pending order.

placing the first simulated trade

(If you’re not familiar with pending orders, you can learn more in our forex trading guide.)

For both market and pending orders, it’s possible to add comments, trailing stops, or auto-break/even rules.

Presets

These remain in effect for all future trades until you modify or delete them.

Now that you’ve placed your trade, you can move forward in the simulation and see how the trade played out.

Trade outcome

Rinse and repeat until you reach the end of your data set.

Modifying Simulated Trades

The procedure we discussed above summarizes how forex backtesting works in a nutshell.

Although it was pretty comprehensive, we didn’t touch on a key issue, namely, how to modify an open trade in the simulation.

From having made a mistake to wanting to move your stops into breakeven or adjusting the profit target, there could be numerous reasons why you find yourself facing this issue.

So, here’s the thing:

On your Soft4FX dashboard, click the “Trades” button.

Modifying simulated trades

This brings up a window that shows your market and pending orders. You can also check some statistics here, but we will get into that later.

For now, just click “Modify”.

Modify

Depending on your trade, a few lines will appear on the chart representing your TP, SL, and entry level (for pending orders). You can manually drag each line and move it wherever you want. The risk-to-reward ratio will be calculated in real-time, as will the dollar amounts.

Modifying the trade

Once you finish, click “Accept” and the order is modified.

Advanced Backtesting Techniques

In this section, we’ll talk about some “advanced stuff” that you might need at some point in your backtesting.

Specifically, you’re going to learn how to test your strategy with multiple timeframe analysis, how to scale out of your simulated trades, and how to account for news events.

Let’s get into that one by one.

Multiple Timeframe Analysis

Multiple timeframe analysis is just what it sounds like: Using multiple timeframes for trading.

Most traders who use this technique monitor three different timeframes, such as the daily, four-hour, and hourly. The analysis is done from top to bottom, with trades being opened on the smallest TF.

Multiple timeframe analysis is very easy to accomplish with Soft4FX.

To get started, add at least two charts to the simulation using the “Charts” option from the dashboard. For example, we’re going to add the daily and the four-hour chart.

Adding more charts

Make sure you open the charts and navigate to the highest timeframe. In our case, it’s the daily chart.

Once you’re there, do something that resembles analyzing the chart as you would with your strategy. For example, we’re going to draw in the nearest support and resistance zones.

Marking levels on the daily chart

Then select all the lines you want to appear on the lower chart(s) and click “Clone/Update Selected”.

Cloning charts

While doing this, you must stay on the source chart.

After you click, your lines will be visible on each chart you have opened.

H4 chart

Scaling Out of Trades

Scaling out means that you exit your position at different price levels.

If your method also involves scaling in (that is, you divide your risks into smaller position sizes and enter at different price levels), you can scale out simply by systematically closing your trades.

However, if you use scaling as an exit-only tactic, you will need to know how to make partial position closes.

A partial position close means that you close only a certain portion of your position and let the other run. To do that, you must navigate to the “Trades” section and click “Close part”.

Partial position closure

You can either enter a lot amount or choose which percentage of the position you want to get rid of.

Accounting for News

Whether you want to avoid trading around the news or take advantage of it, Soft4FX has you covered.

From the dashboard, select “News”. It will take you to the economic news panel.

News window

Here you can see the upcoming and past news releases along with their expected impact.

We typically like to filter for high-impact events to make it less clustered, but ultimately it’s up to you. Make sure to tick the “show on chart” box. Then you can exit the window.

On your chart, activate the news tab.

Showing news on the chart

It will draw a vertical line to wherever there’s a news event. For upcoming news, there will be a red dotted line, while for news that has already passed, there will be a grey dotted line.

Evaluating Your Performance

This is the last stage of backtesting.

The thing is, “performance” can refer to a lot of things—and many traders out there care about only one aspect, which is profit.

Of course, profit is important, but to really gauge your strategy’s standing, you need to look at some of the other key metrics, including maximal drawdown, average length of trade, and consecutive losses.

To that end, we’ll walk you through these three concepts, explaining why they are essential to sound performance analysis.

Before we get into that, here’s how you can generate a report:

Generating backtesting report
Forex backtesting results

You can also follow your statistics in real-time during backtesting. Just head over to the “Trades” section and change the view to statistics.

Real-time stats

Maximal Drawdown

A drawdown is the reduction of your trading account after a losing period.

drawdown
Source: BabyPips.com

For example, if your account value is $10,000 and it drops to $9,000, your drawdown is $1,000, or 10%.

If you never had a larger capital reduction, then this 10% represents your maximal drawdown.

If, from this $9,000, your account increases to $11,000, the maximal drawdown doesn’t change because the account hasn’t experienced a drop that would have been bigger than the previous drawdown.

If your account begins to fall and reaches $10,000, the proportional reduction is 9.09%, so your maximal drawdown remains 10%. However, if it keeps falling and reaches $9,000 again, your drawdown will change to 18.18%.

The maximum drawdown is calculated for equity, meaning it considers your account balance plus the value of floating positions.

The exact formula looks like this:

(Equity Peak – Equity Trough) / Equity Peak

As you can see, maximal drawdown is irrespective of the deposit.

This is in contrast to the absolute drawdown, which shows how much the balance has decreased in relation to the initial deposit.

For example, if you started with an $11,000 deposit and its lowest point below the deposit was $10,000, your absolute drawdown would be 10%.

Even if you keep trading and grow the account to $14,000 and then suddenly lose all the profits and finish at breakeven, the absolute drawdown stays at 10% because this is the maximum you ever lost from the initial account balance.

Looking at only this number is misleading because, in reality, you experienced a much more severe losing period, as shown by the maximal drawdown, which would have been 28.57% in this case.

To conclude, we recommend that you focus on the maximal drawdown when evaluating your performance.

Every trader experiences drawdowns, but successful traders can withstand these losing periods both mentally and financially. If your drawdown is too high, consider risking less of your account per trade.

ForexTrainingGroup has a great guide on the topic of drawdowns if you are more interested.

Average Length of Trade

A trade that takes you less than a minute to finish during backtesting might take weeks or months in reality.

It’s one thing to instantly see the outcome, but a completely different thing to watch your position fluctuating up and down while staying calm and sticking to your plan.

There are two great advantages of looking at the average trade length metric:

  • It gives you a sense of stability if you know when you can expect to close your positions.
  • It indicates whether your strategy falls short of your preferred trading style.

The only problem is that it’s not included in the report so you need to calculate it manually using Excel.

Open your backtesting statement and highlight the transactions section.

Copying the data

Use the shortcut key combination Ctrl+C to copy the text and paste it with Ctrl+V into an Excel spreadsheet.

Then, add a new column titled “Trade Length”.

To get the number of days, weeks or years between two dates, use the DATEDIF function.

Datedif usage

You can automatically fill the formula to the other cells by simply selecting the cell that has the formula, resting your cursor in the lower-right corner and dragging the fill handle down.

Backtesting data in Excel

If you happen to have these empty values like we have, sorting the list by ascending order will do the trick.

Finnaly, you can summarize the values using the SUM function and divide by the number of trades which is shown on the backtesting statement.

Calculating average length of trade

Consecutive Losses

Both winning and losing streaks happen quite often, and while nobody complains about extended winning streaks, most people become worried when they run into a few losses in a row.

It’s pretty unfortunate, as if you’re afraid of being wrong, trading psychology will cause you to do something that ends up making you wrong.

A solution to this is looking at the consecutive losses of your backtesting data.

Consecutive losses

If you know that your otherwise profitable strategy will eventually produce, say, eight losing trades in succession, you will be less stressed after the fifth losing trade.

It probably makes sense.

The less uncertainty you face, the more likely you are to retain your objectivity and avoid the emotional pitfalls of trading. That’s why we do this whole forex backtesting thing in the first place.

Conclusion

Backtesting is essential. If you’re getting started with forex, struggling to see results, or just wanting to improve yourself, you need backtesting.

And you don’t need just backtesting; you need proper backtesting.

With this guide, you’re certain to learn how to properly backtest a trading strategy. This will help you grow as a trader and eventually make money.