Guide

How to backtest a trading strategy

A backtest runs your rules over past prices to see what they would have done. Done properly, it tells you whether a setup is worth real money before you risk any.

Updated: 5 min readReviewed by Andrii Levchenko

A backtest answers one question: if you had followed these rules in the past, would they have made money? It does not promise the future. It filters out ideas that never worked, and it gives you a baseline to compare live results against.

Manual or automated backtesting

Manual backtesting means scrolling the chart bar by bar, taking each setup by your rules and logging the result. It suits discretionary strategies, where part of the decision is reading the chart. It is slow, and it trains your eye at the same time.

Automated backtesting means coding the rules as an expert advisor or script and letting software run them over years of data in minutes. It suits strategies that can be written down without exceptions. The risk is that it is easy to tune the rules until they fit the past. How it works in MetaTrader 5 is covered in the MT5 Strategy Tester guide.

Most retail traders start manually. If the rules hold up, automation is the next step.

Step 1. Write the rules down

A backtest is only as good as the rules. Write them before you open the chart:

  • Market and timeframe. For example, EUR/USD on the 15-minute chart, London session only.
  • Entry. The exact condition. "Strong trend" is not a rule. "Price closes above the 20-period high" is.
  • Stop loss. Where it goes and why.
  • Exit. A fixed target in R, a trailing rule or a time exit.
  • Filters. News, sessions, days you do not trade.

If two people could read your rules and take different trades, rewrite them. A trading plan template helps you put them on one page.

Step 2. Choose the data and the period

Use the instrument and timeframe you will trade. Cover different conditions: a trending stretch, a range and a volatile period. For a 15-minute strategy, six to twelve months is a reasonable start. For daily charts you need several years to collect enough trades.

Check that your data includes the spread, or add it by hand. A strategy with a 5-pip target can look profitable on mid prices and lose money once a 1-pip spread is added.

Step 3. Take the trades and log every one

Hide the right side of the chart, move forward one bar at a time and act only on what you can see. For each trade, log the date, direction, entry, stop, exit and result in R. Log losers with the same care as winners, and log the setups you skipped too.

Aim for at least 100 trades. Fewer than 30 tells you almost nothing, because a run of five winners in a row is normal for a random coin.

Backtester replaying EUR/USD bar by bar with positions on the chart
Backtester replaying EUR/USD bar by bar with positions on the chart

Step 4. Read the results in R

Money results depend on position size. R results do not, so they compare cleanly. The numbers to read, in this order:

  1. Expectancy. Total R divided by the number of trades. Above zero means the rules made money over this sample. Read more in the R multiple guide.
  2. Number of trades. Small samples make any number unreliable.
  3. Maximum losing streak and drawdown in R. This is what you will have to sit through live. Size it with the drawdown guide.
  4. Win rate and average win in R. Together they explain where the expectancy comes from.

Then split the results: by session, by weekday, by long and short. A setup often works in one session and loses in another. Trade analysis shows how to read these breakdowns.

Step 5. Forward-test before going live

A backtest shows the past. A forward test checks that you can follow the rules in real time. Trade the strategy on a demo or with minimal size for 20 to 50 trades and compare the expectancy with the backtest. If live results fall far below the backtest, look for rules you are not following or conditions the backtest did not see.

Mistakes that make a backtest lie

  • Look-ahead bias. Taking a trade because you already saw where price went. Hide the future bars.
  • Curve fitting. Adjusting rules after every loss until the past looks perfect. Change one thing at a time and retest on a fresh period.
  • Ignoring costs. Spread, commission and slippage matter most for short-term strategies.
  • Cherry-picking periods. Testing only the months where the setup obviously worked.
  • Too few trades. Ten good trades are a story, not a statistic.

Where Tradeart fits

Tradeart has a built-in backtester: 15 instruments, two of them at once, replayed candle by candle on real market history. Each session gets a report, and the simulator replays your trades with other stop and target choices. When you trade the strategy live, the journal imports trades from MetaTrader 5, cTrader and DXtrade, so backtest and live results sit side by side, both in R.

Frequently asked questions

How many trades do I need in a backtest?

At least 100 for a strategy that trades often. Under 30 trades the result is mostly noise.

Is manual backtesting worth the time?

Yes for discretionary strategies. You learn the setup at the same time, and you see the situations an automated test would code away.

Why do live results differ from the backtest?

Common reasons are costs left out of the test, rules followed loosely in real time, hindsight in the test and a market that changed. Compare live trades with the backtest in R to find which one it is.

Can I backtest without coding?

Yes. Replay the chart bar by bar, take trades by your written rules and log them in a spreadsheet or a journal. Coding is only needed for automated tests.

Start today

Your edge is
in your history.

Start free trial7 days free · No credit card