A backtest replays your rules on historical data. Done well it saves you money; done badly it gives false confidence. Here are the basics and the traps.
Backtesting means running your trading rules over past price data to see how they would have performed. It is the cheapest way to reject a bad idea, and the most common way to fool yourself into trusting one.
What a backtest should tell you
- How many trades the rules produce, and how often.
- The win rate, average win and average loss.
- The profit factor (gross profit divided by gross loss).
- The maximum drawdown - the deepest fall from a peak.
- How results change across years, market conditions and directions.
Include the real costs
A strategy that makes $3 per trade before costs can easily lose money after them. Always include:
- Spread - ideally the real spread at each moment, not a fixed average.
- Commission per lot.
- Swap if trades are held overnight.
- Slippage on stop orders and during news.
On fast instruments like gold, these costs often decide whether a scalping strategy is profitable at all.
The most common backtest mistakes
- Lookahead bias - the code uses information that was not available at the time, such as the close of a bar that has not finished yet, or a higher-timeframe value before that bar closed. This can turn a losing strategy into a beautiful equity curve.
- Curve fitting - tuning many parameters until the past looks perfect. The rules end up describing noise.
- Too little data - 30 trades prove nothing. Aim for hundreds, across different market regimes.
- Unrealistic fills - assuming a stop or limit always fills at its exact price, or that a trailing stop moves to a level above the current price and still fills.
- Survivorship and selection - testing only the period or symbol where the idea looked best.
Split your data
Keep part of your history aside. Develop and tune on the first part (in-sample), then run the finished rules once on the rest (out-of-sample). If the results collapse out-of-sample, the strategy was fitted to the past. A useful habit is to check each half of the data separately: a real edge should appear in both.
Then confirm forward
After a good backtest, run the strategy on a demo or very small live account for several weeks. Compare entries, exits and costs trade by trade with what the backtest predicted. Gaps usually come from spread, execution or data differences - and it is far cheaper to find them with small size.
Bottom line
A backtest is a filter, not a guarantee. Use it to throw away weak ideas quickly and to understand the risks of the good ones.
Trading forex and gold carries a high level of risk and may not be suitable for every investor. Past performance and backtests do not guarantee future results. This article is education, not financial advice.
