How to Backtest a Trading Strategy (Without Fooling Yourself)
A backtest runs a set of trading rules over historical data to see how they would have performed. Done well, it tells you whether an idea has an edge before you risk money. Done badly, it produces beautiful equity curves that fall apart the moment you trade them.
This guide walks through a proper backtest step by step, and the mistakes that most often create fake results.
- Write rules so precisely that two people would take the same trades.
- Include spread, commission and slippage. Many small-target strategies only work without them.
- Aim for 100+ trades, across several years and market conditions.
- Test on more than one market and on data you did not use to design the rules.
In this guide: Step 1: write the rules precisely · Step 2: use real data and include costs · Step 3: get enough trades · Step 4: read the right numbers · Step 5: check it is not overfitted · Step 6: forward test before going live · Manual backtesting vs software
Step 1: write the rules precisely
Vague rules make vague backtests. 'Buy when the trend is up and price pulls back' can be read a dozen ways. Precise rules look like this: 'Buy when RSI(2) crosses below 10 and price is above the 200 SMA. Exit when RSI(2) crosses above 70. Stop at 3x ATR.'
Every rule needs an entry condition, an exit or target, a stop loss and a position size. If you trade a time window, such as the New York session, include it. WickCheck reads rules written exactly like this in plain English and shows how it interpreted each one before running the backtest, so you can check nothing was misread.
Step 2: use real data and include costs
Use real historical candles for the market and timeframe you will trade. Then add trading costs: spread, commission and slippage. On strategies with small targets, costs can be the difference between a profit factor above and below 1.
Also check how the test treats candles where both stop and target fall inside the same bar. Assuming the target was hit first flatters results; WickCheck counts the stop first unless lower-timeframe data says otherwise.
Step 3: get enough trades
Results from 20 trades are mostly noise. Aim for 100 or more, spread across different years. Our strategy library shows why: the ICT Silver Bullet on Nasdaq produced only 27 trades in a year, far too few to judge either way, while the RSI(2) pullback on S&P 500 futures has 87 trades over 10 years. See sample size.
Step 4: read the right numbers
- Profit factor: above 1 made money after costs.
- Expectancy: average result per trade in R.
- Max drawdown and longest losing streak: can you live through them?
- Year-by-year results: is the profit spread out, or did one year do everything?
- Long vs short: does one side carry the strategy?
Win rate on its own is the least useful of these. Our guide to tracking trading profit and loss explains each metric.
Step 5: check it is not overfitted
Overfitting is tuning rules until they fit past data perfectly. The more filters and exact parameters you add, the better the backtest and the worse the live results.
- Test other markets. The 20-day breakout is profitable on all 9 markets in our library with identical rules. That is much stronger evidence than one great market.
- Test unseen data. Design on older data, then check the most recent years. A walk-forward test automates this.
- Shuffle the trades. A Monte Carlo test reruns the trade sequence in random orders to show how bad drawdowns could plausibly get.
- Keep it simple. If a rule only works with RSI at 27 and not 25 or 30, it is probably fitting noise.
Step 6: forward test before going live
A good backtest earns a forward test, not a full-size live account. Practise the rules in chart replay, then trade small or on demo, and compare results with the backtest in your trading journal. Our guide to backtesting vs forward testing covers this stage.
Manual backtesting vs software
Manual backtesting, scrolling charts and logging trades, builds intuition but is slow and prone to hindsight bias: you know where price went. Automated backtesting is fast and consistent but used to require code such as Pine Script or Python. No-code tools like WickCheck remove that barrier: describe the rules in plain English and test them on years of data in seconds, then export to TradingView Pine Script if you want. See no-code backtesting.
Bottom line. Precise rules, real data, real costs, enough trades and a check on unseen markets and years. Skip any of those and the backtest is telling you a story, not a result.
Type your rules, see how they were read, and get results on years of real data with costs included.
Questions
- How do I backtest a trading strategy?
- Write precise entry, exit, stop and sizing rules, run them over years of real historical data with spread and slippage included, collect at least 100 trades, read profit factor, expectancy and drawdown, then check the result on other markets and unseen data.
- How many trades do I need in a backtest?
- At least 30 for a first impression and ideally 100 or more across several years and market conditions. Results from 20 or 30 trades can easily be luck.
- Can I backtest without coding?
- Yes. No-code backtesters like WickCheck let you describe a strategy in plain English and test it on historical data, with costs included, without writing Pine Script or Python.
Keep reading
Backtesting vs forward testing (paper trading) vs demo trading: what each one proves and the order to use them before trading real money.
How to Track Trading Profit and Loss: The Metrics That MatterHow to track your trading P&L properly: profit factor, expectancy, R multiples, win rate, drawdown and equity curves, with worked examples and benchmarks.
Losing Streaks in Trading: How Many Losses in a Row Are Normal?How long losing streaks get at different win rates, the exact odds over 100 trades, what they cost at 1% risk, and how to survive them.
EMA Crossover Strategy on Gold: What the Backtest ShowsWe tested the 9/21 EMA crossover with a 200 EMA filter on gold, EUR/USD and the Nasdaq, with costs included. Gold lost money after costs over 10 years.
Educational content, not investment advice. Trading involves risk of loss.