How to backtest a forex strategy
By DT Terminal · Published · Updated
A backtest is only evidence if the rules were written before the test and every trade was logged during it. Write the strategy so a stranger could follow it: the entry, the exit, where the stop goes, how size is chosen, and which sessions it trades. Pick a period long enough to contain trends, ranges, quiet weeks and news days, and aim for at least a hundred trades rather than a tidy month. Replay the chart bar by bar so you never see the candle you are deciding on. Log each trade with its reason and its mistakes as you go. Then read expectancy, the average result per trade in R, rather than the shape of the equity curve. Run the same rules on a demo account before any money is involved, and go live small.
In order. Steps one and two are done away from the chart, and skipping them is what turns a backtest into a story about the past.
01Write the rules before you open a chart
A strategy you can test is one a stranger could execute without asking you a question. That means five things in writing: what has to be true to enter, where the stop goes, how the trade is exited when it works, how position size is decided, and which sessions or days the strategy trades at all.
Anything you leave vague will quietly be decided in your favour once the bars are moving, and the result will be a record of your hindsight rather than a test of the rules. If a rule cannot be written down, it is a discretionary judgement, which is fine, but then what you are testing is your judgement and the sample needs to be bigger.
- Entry conditions, stop placement, exit rules, sizing, and the sessions it trades
- Name the strategy, so every trade you log can point at this version of it
- Write the conditions you will not trade in, such as the minutes around a release
02Pick a period that contains more than one market
The point of choosing a period is to include conditions you will actually meet: a trend, a range, a quiet holiday week and at least a few high impact releases. A test that covers one clean trending quarter tells you how the strategy behaves in a trend and nothing else.
Sample size matters more than calendar length. A hundred trades is a reasonable floor for an intraday strategy, and getting there on a 5 minute chart usually takes several months of data. For a swing strategy on 4 hour or daily bars, the same hundred trades may take a few years.
Know what your data can and cannot support. The DT Terminal backtester covers forex, metals, crypto and CME futures including the US index contracts. On Pro and up the 1 minute candle forms second by second as it plays, and Ultra adds 1s to 30s charts, with fills checked tick by tick on Ultra where the market has ticks, so you can see what happened inside a minute. Seconds history is deepest on the main markets so far. There are no stocks, and futures cover about the last 2 years, with their seconds as 1 second bars (futures have no ticks). A strategy whose edge lives inside the spread cannot be settled in any tool, and the spread and slippage you assume are yours to justify.
- Cover a trend, a range and a news week, not one flattering quarter
- Aim for a hundred or more trades before you believe a win rate
- Check the data actually exists for the symbol and timeframe you trade

03Replay bar by bar, never scrolled
The mechanical requirement of an honest manual backtest is that you cannot see the candle you are deciding on. Scrolling a chart backwards and marking entries is not a backtest, because the outcome is already on the screen.
So step the replay forward one bar at a time and decide with only what is left of the chart. In DT Terminal the space bar plays and pauses, the arrow keys step a candle, and L and S open a long or a short at the cursor price. Set the risk percentage and a commission per lot when you create the session, so the simulated cost resembles what you actually pay.
- One bar at a time, deciding before the bar closes where the rules say so
- Set risk and commission at the start, so the result is net of costs
- Keep the session to one strategy, so the sample means something

Free accounts keep up to 2 backtest sessions at a time, up to 50 trades each, on one instrument per session. Delete one to start another. Plus, at $9 a month, keeps 3 sessions at a time and allows more markets in a session and more indicators on a chart. Pro is $24 a month and removes the session, trade and indicator caps, raises the market cap again, and adds offline session downloads.
04Log every trade while you are in it
Record the trade as you take it, not from the summary afterwards: the setup, the reason, the stop and target at entry, and any rule you broke. A backtest with no reasons attached can tell you the strategy lost money, but not whether the strategy lost money or you did.
It helps to name what the session is for before it starts. Practicing a setup, validating a written strategy, and drilling one weakness such as moving stops are three different sessions, and mixing them produces a sample you cannot read.
- Reason and mistakes on the trade itself, while the bar is still on screen
- One session, one purpose, so the numbers answer one question
- Screenshot the chart at entry when the setup is visual
05Read expectancy, not the equity curve
An equity curve is a picture, and over a small sample it is mostly a picture of luck. The number that answers whether the strategy is worth trading is expectancy: the average result of a trade, expressed in R, where one R is the amount you risked.
Expectancy of plus 0.2R means each trade returned a fifth of what it risked on average, so a hundred trades returned about 20R before you touch position sizing. It combines win rate and average win against average loss, which is why a 40% win rate can beat a 70% one. Read it beside the sample size, the largest losing run and the maximum drawdown, because those decide whether you could have sat through it.
Then look for where the result comes from. If the whole edge sits in one instrument, one session or three outlier trades, you have found a coincidence rather than a strategy.
- Expectancy in R, with the trade count beside it
- Longest losing run and maximum drawdown, because those are what you have to endure
- Break the result down by instrument, session and day, and see if it survives

06Run it on a demo account before any money
A backtest is a test against known history, and you were the one choosing which bars to trade. A demo run removes both problems: the same written rules, on prices nobody has seen yet, at the times you would really be at the screen.
Log the demo trades in their own right, in a separate account so they never touch your live numbers. A demo account at your broker is the right home for them, because its fills come from live prices at the spread you would really pay.
Run it long enough to hit a real sample and to include a week you would rather forget. If the demo numbers look nothing like the backtest, the difference is usually spread, slippage, or the trades you took in the test that you would never take at 3am.
- Same rules, unseen prices, real session times
- A separate account, so practice never flatters your live record
- Compare expectancy against the backtest, not the profit
07Go live small, and keep comparing
Live trading adds the two things neither test can simulate: your money and your nerves. Start at a size where a losing run is boring, and keep logging the same fields with the same tags, so the live sample can be read against the tested one.
The comparison is the whole point of having journalled the backtest. Same strategy tag, same fields, three columns: backtest, demo, live. Where live expectancy falls short, the gap is either execution, which your mistake tags will show, or costs, which your commission and swap fields will show.
- Size so that the drawdown you measured is survivable
- Same tags across backtest, demo and live, or the comparison is meaningless
- Review by strategy, not by day, once there is a live sample to read
A hundred is a reasonable floor, and more is better for anything with a win rate near half. Below about thirty trades the result is mostly noise: a run of five winners moves the win rate by more than any rule change you are testing. Sample size matters more than how many months the test covers, so a fast intraday strategy can reach a usable sample in a quarter while a swing strategy takes years.
Expectancy is the average result of a trade measured in R, where one R is what you risked on it. Add up the results of every trade in R and divide by the number of trades. Plus 0.3R means a typical trade returned about a third of the risk taken. It answers the question a win rate cannot, because a strategy that wins 35% of the time with three R winners beats one that wins 70% of the time with quarter R winners.
Yes, with limits everywhere. A free DT Terminal account keeps 2 sessions at a time, up to 50 trades each on one instrument, which is enough to test the method and one strategy. Backtestingmax gives unlimited free sessions on the last 12 months of forex and metals, and the MetaTrader 5 Strategy Tester is free if your strategy is written as an Expert Advisor. Our guide to backtesting tools compares what each free tier actually allows.
They answer different questions. Automated testing runs written rules over years of data in seconds, so it tests the rules and finds out quickly whether an idea is worth more of your time. Manual replay tests you executing the rules, including the trades you talk yourself into. If your strategy is fully mechanical, automate it. If it involves judgement, a bar by bar replay is the only test that includes the part most likely to fail.
Write the rules first and do not edit them mid test. Never scroll forward to see the outcome before you decide. Log the trades you skipped as well as the ones you took. Keep the whole sample rather than the sessions that went well, and count a trade you would have hesitated on as taken. If you change a rule, that is a new test with a new sample, not a correction to the old one.
Until the sample is large enough to compare and includes at least one bad stretch, which for most intraday strategies means a month or two rather than a week. What you are checking is whether live expectancy resembles the tested expectancy at the same risk, and whether you actually took the trades when they appeared rather than after they worked.