Backtesting Your Strategy: A Step-by-Step Guide
What Backtesting Actually Proves (and Doesn't)
Backtesting means running a strategy's rules against historical data to see how it would have performed. Done properly, it's the difference between a strategy you genuinely believe has an edge and one you simply "feel" works because you remember the times it hit.
It's worth being precise about what backtesting does and doesn't prove: it shows that a strategy had a documented edge in the past, under the specific conditions tested. It does not guarantee that edge persists going forward — markets change, and volatility regimes shift. What it does provide is a foundation: a strategy with no historical edge has no real basis for live trading at all, while one with a documented edge across varied conditions gives you something concrete to build on.
Step 1: Write Mechanical, If/Then Rules
Before opening a single historical chart, your strategy needs to be specific enough that two different people could apply the same rules and reach the same conclusions. "Buy when it looks like support" isn't testable. "Buy when RSI(14) crosses below 30 and price is above the 200 EMA on the H1 timeframe" is.
Every element needs a clear rule: entry trigger, stop-loss placement, take-profit or exit condition, and position sizing. If you can't write it as an if/then statement, you can't backtest it meaningfully.
This connects directly to How to Build a Trading Plan and its condition/trigger/invalidation framework.
Step 2: Hide Future Data to Avoid Hindsight Bias
This is widely considered the single most common backtest-killing mistake: hindsight bias, where seeing future price action while reviewing past entries makes trades look far more obvious than they actually were in real time. Scrolling backward through a chart with everything already visible naturally biases you toward "seeing" setups that worked.
The fix: test with future candles hidden, scrolling forward one bar at a time, and only marking an entry when your rules would have genuinely triggered at that exact moment — not because you can see what happened three days later.
Step 3: Log Every Trade, Including Losers
Every trade your rules would have triggered needs to be logged, including the ones that lost badly. Skipping uncomfortable losing trades, even unintentionally, skews the results toward a rosier picture than the strategy actually deserves. A backtest's value comes specifically from including the full, honest picture — wins, losses, and everything the mechanical rules would have actually done.
Step 4: Split Your Data for Out-of-Sample Testing
A common, effective approach: split your historical data into two periods. Use the earlier roughly 70% to develop and refine the strategy. Then test the final 30% — data you haven't touched during development — without making any further adjustments.
If performance holds up reasonably well on that untouched data, the edge is more likely genuine. If results fall apart, the strategy was probably overfitted — tuned to match the specific historical window it was built on, rather than reflecting a real, repeatable pattern. A more rigorous version of this same idea, walk-forward analysis, repeats the process across multiple rolling periods rather than just one split.
Step 5: Read the Metrics That Actually Matter
- Win rate — the percentage of trades that were profitable, over a meaningful sample.
- Profit factor — gross profit divided by gross loss. Below 1.0 means the strategy loses money overall; roughly 1.3-1.8 is commonly considered solid; above 2.0 is excellent but worth double-checking for overfitting.
- Maximum drawdown — the largest peak-to-trough decline in account equity historically. Below 10% is conservative; 10-20% is normal and manageable; above 30% is a serious red flag for account survivability.
- Sample size — at least 100, and ideally 200+, trades before drawing real conclusions. Fifty trades or fewer is generally too small a sample to separate genuine edge from random variance.
Win rate and profit factor need to be read together, not separately — a 40% win rate with a strong reward-to-risk ratio can outperform a 70% win rate with a poor one.
See Risk-Reward Ratio Explained for the full math behind why this pairing matters.
Step 6: Account for Real Trading Costs
A backtest that ignores spread, commission, and slippage will overstate performance — sometimes turning what would be a losing live strategy into an apparently profitable backtest. Building realistic frictional costs into the test from the start, rather than adding them as an afterthought, is essential for results that actually mean something.
See What Is a Pip, Lot, and Spread in Forex? for how spread cost is calculated per trade.
Common Backtesting Mistakes
- Overfitting. Tweaking rules endlessly until they match one specific historical window perfectly — this produces a fragile system that breaks down under live, unseen conditions.
- Ignoring frictional costs. Spread, commission, and slippage can turn a winning backtest into a losing live strategy.
- Insufficient sample size. Basing conclusions on a few weeks of favorable price action rather than years of data across multiple market conditions.
- Skipping out-of-sample testing entirely. Testing only on the data used to build the strategy all but guarantees an inflated, unrealistic result.
A Common Backtesting Trap
Say you're backtesting a strategy on EUR/USD daily charts, scrolling forward candle by candle. If you catch yourself glancing slightly ahead — even unconsciously noticing that a big move is coming a few candles later — your entries start getting subtly influenced by information you wouldn't have had in real time. This is hindsight bias, and it's one of the most common ways backtests produce misleadingly good results.
A more reliable approach uses dedicated backtesting software that reveals price one candle at a time, with no ability to see ahead, or strictly disciplined manual scrolling with a ruler or cover over the future price action. The extra friction is worth it — a backtest contaminated by hindsight bias isn't just unhelpful, it's actively misleading about how a strategy will perform going forward.
Frequently Asked Questions
What is hindsight bias in backtesting and how do you avoid it?
Hindsight bias happens when you can see future price action while testing past entries, making trades look more obvious than they actually were in real time. It's avoided by testing with future candles hidden, scrolling forward one bar at a time so decisions are made with only the information that would have been available at that moment.
How many trades do you need for a reliable backtest?
Most serious backtesting guidance suggests at least 100, and ideally 200 or more trades, before drawing meaningful conclusions. A sample of 50 trades or fewer is generally considered too small to distinguish genuine edge from random variance.
What is out-of-sample testing?
Out-of-sample testing means reserving a portion of historical data — commonly the most recent 30% — that isn't used while developing or refining the strategy. Testing the finished rules against this untouched data checks whether the edge is real or the strategy was simply overfitted to the data it was built on.
What is profit factor and what is considered a good number?
Profit factor is gross profit divided by gross loss. A value below 1.0 means the strategy loses money overall. A range of roughly 1.3 to 1.8 is commonly considered solid for a realistic trading strategy, while values above 2.0 are excellent but also worth double-checking for overfitting.