How to backtest a trading strategy.
A practical, honest guide to testing a strategy on historical data: rules, quality data, realistic costs, the metrics that matter and how to avoid fooling yourself.
ZENKEI
A practical, honest guide to testing a strategy on historical data: rules, quality data, realistic costs, the metrics that matter and how to avoid fooling yourself.
To backtest a trading strategy, you turn it into precise rules, run it over quality historical data with realistic spread, slippage and commission, and judge it on drawdown and robustness, not just profit. Then you validate with walk-forward and out-of-sample testing, and forward-test on a demo account before risking real capital. The goal is not a pretty equity curve; it is an honest read of how the strategy behaves.
Backtesting is running a trading strategy over historical price data to see how it would have performed. It turns a set of rules into a track record of simulated trades, giving you a way to judge and refine the strategy before any money is at risk. Done well, it builds understanding and confidence. Done carelessly, it produces a beautiful backtest that loses money live, which is worse than no test at all.
Write down precise conditions for entries, exits, stops and sizing. If you cannot state it as unambiguous rules, you cannot backtest it, only guess.
Use clean data that covers different regimes: trends, ranges and volatile periods. Bad or gap-filled data quietly ruins a backtest before it starts.
Match the tool to where the strategy will run: MetaTrader's Strategy Tester for MQL, TradingView for Pine Script, or Python for custom research.
Include spread, slippage and commission. Many "profitable" strategies are just ignoring trading costs, and turn into losers once you add them.
Look past net profit. Maximum drawdown, profit factor, expectancy, win rate and the number of trades tell you whether an edge is real and survivable.
Do not tune parameters until the past looks perfect. A strategy fitted to noise fails live. Prefer fewer, robust parameters over a dozen finely-tuned ones.
Confirm the result with walk-forward and out-of-sample data, then run it on a demo account in real time before committing capital.
Net profit is the least useful number on the report. These are the ones worth reading:
We turn a strategy into a coded system and backtest it honestly, with realistic costs and walk-forward validation, as part of our Expert Advisor development and strategy to Expert Advisor services. New to automation? See how to build an Expert Advisor.
Backtesting is running a trading strategy over historical price data to see how it would have performed. It turns a set of rules into a track record of simulated trades, so you can judge the strategy before risking real capital.
Enough to cover different market conditions: trends, ranges and volatile periods, and ideally several years and a few hundred trades. A strategy that only saw one kind of market tells you little about how it behaves in another.
Curve-fitting, or overfitting, is tuning a strategy's parameters so it fits past data almost perfectly. It produces a beautiful backtest that fails live, because the settings were shaped to noise rather than a real edge. Walk-forward testing and out-of-sample data guard against it.
No. A backtest shows how a strategy behaved in the past under your assumptions, not what it will do next. Markets change. A solid, honestly tested backtest improves your odds and understanding, but it is not a guarantee.
MetaTrader's Strategy Tester for MQL Expert Advisors, TradingView's Strategy Tester for Pine Script, and Python libraries for custom research. The right tool depends on where the strategy will run and how much control you need.
Bring your strategy. We code it and backtest it properly, source code included.