A backtest applies a set of trading rules to historical prices to see how they would have performed. Done well, it filters out ideas that never had an edge. Done carelessly, it produces beautiful equity curves that vanish the moment real money is involved. The difference is mostly discipline, not software.
Start with a rule you can write down
A testable idea is unambiguous. "Buy when the trend looks strong" is not testable. "Buy at the next open after the close is above the 50-day average and the prior day's range was below its 14-day average, with a stop 1.5 times ATR below entry" is. If two people could read your rules and take different trades, they are not yet rules. Discretionary methods can still be reviewed, but through a journal rather than a mechanical test; see the trading journal guide.
Decide the questions before you look at results
Before running anything, write down what you will measure and what result would make you reject the idea. Typical measures:
- Number of trades.
- Win rate and average win versus average loss.
- Expectancy: average result per trade, in units of risk (R). If your stop represents 1R, a trade that makes twice the risk is +2R.
- Maximum drawdown and the longest stretch without a new equity high.
- Longest losing streak. This is the figure that will test you psychologically; see losing streaks and revenge trading.
Sample size matters more than the equity curve
Thirty trades is a story, not a statistic. A strategy with a true 50 percent win rate will, by chance alone, show runs that look like skill or incompetence in small samples. There is no magic number, but hundreds of trades across different market conditions give far more reliable information than a few dozen. If your rules generate too few signals to reach a meaningful sample, you may need to test on more pairs or longer history, or accept that the idea cannot be validated.
Include realistic costs
The most common reason a backtest fails live is that it ignored friction. Include:
- Spread. Use the spread you actually pay, not the minimum. Spreads widen at rollover and around news.
- Slippage. Stops and market orders fill worse than planned in fast markets. See forex order types explained.
- Commission and swap. Holding positions over multiple days accrues financing; see the carry trade explained.
A system that makes 0.3 pips per trade before costs makes nothing after them.
Beware the classic biases
- Look-ahead bias. Using information that was not available at the decision time, for example entering at a day's low because the full-day data was in the dataset. Make sure each signal uses only data that had closed.
- Survivorship and selection bias. Choosing only pairs and periods where the idea worked.
- Data snooping. Testing dozens of variations and reporting only the best one. If you try 100 random parameter combinations, a few will look good by luck.
- Overfitting. Tuning parameters until they fit the past exactly. An over-fitted rule describes noise. The more parameters and special cases a system has, the more suspicious you should be.
Use out-of-sample data
Split history into two parts. Develop and tune on the first (in-sample). Then test the frozen rules once on the second (out-of-sample) without changing anything. If performance collapses, the first result was probably noise. A more demanding approach is walk-forward testing, which repeats this process across rolling windows. Whatever you choose, use the out-of-sample result only once; if you keep tweaking until it looks good, it stops being out-of-sample.
Check robustness, not perfection
Nudge your parameters slightly. If a 50-period average works but 45 and 55 fail, the result is fragile. Robust ideas tend to work across a range of settings, across several pairs, and across different regimes, such as trending and ranging years. Look at performance by year and by session (see trading sessions), and ask whether one single period produced most of the profit.
Translate results into risk
A backtest drawdown is a floor, not a ceiling. The worst drawdown in your sample is not the worst possible. Plan for something worse, perhaps 1.5 to 2 times the historical figure, and use that to decide your risk per trade. If the plausible drawdown would make you quit, reduce size now. Methods are in position sizing and risk per trade.
Forward test before going live
After the backtest, run the rules on a demo or at the smallest practical live size for a meaningful number of trades. Compare real fills with your assumptions. Differences in spread, slippage and your own execution discipline show up quickly. Keep logging every trade and compare against the backtest expectancy.
A short checklist
- Rules are fully written and unambiguous.
- Success and rejection criteria are set in advance.
- Sample is large and spans different conditions.
- Costs and slippage are included.
- No look-ahead; parameters few; variants counted.
- Out-of-sample result held up.
- Small forward test confirms the assumptions.
The goal of backtesting is not to prove you are right. It is to give a flawed idea a fair chance to fail cheaply, on paper, rather than in your account.
This article is educational and not investment advice. Past performance, simulated or real, does not guarantee future results. Leveraged FX trading carries a high risk of loss.