What is backtesting? How to backtest a trading strategy

GuidesDeutsch

What is backtesting? How to backtest a trading strategy

Backtesting is running a trading strategy's rules over historical market data to see how they would have performed. A backtest replays the past bar by bar or tick by tick, fills each order with realistic prices and costs, and reports the profit, the drawdown and every trade, before any money is at risk.

Updated · Orion Quant Technologies

How does a backtest work?

A backtest feeds historical prices to the strategy in time order, one bar or one tick at a time. At each step the strategy sees only what was known at that moment, decides whether to buy, sell or close, and a simulated broker fills the order at the price that was available, minus spread, commission and swap.

When the data runs out, the engine adds up the trades into an equity curve and a set of statistics. The result is only as honest as three things: the data, the fill model and the costs.

How do you backtest a trading strategy step by step?

Every serious backtest follows the same seven steps, whatever the platform:

  1. Write the rules down so a machine can follow them: entry, exit, stop, target and position size.
  2. Pick the market and the period. Use years, not weeks, and include calm and volatile stretches.
  3. Choose the data resolution. Daily or hourly bars for a first look, minute bars or ticks for anything with tight stops.
  4. Set the costs the broker would charge: spread, commission per lot and side, and overnight swap.
  5. Run the backtest and read the trade list, not only the final profit.
  6. Test robustness: out of sample data, walk forward windows and a Monte Carlo reshuffle of the trades.
  7. Paper trade it on live data before real money.

Which numbers matter in a backtest?

Net profit alone says little. These are the figures that tell a working strategy from a lucky one:

MetricWhat it tells you
Maximum drawdownThe largest fall from a peak in equity. The pain you would have sat through.
Profit factorGross profit divided by gross loss. Above 1 makes money, before you ask how reliably.
Number of tradesThe sample size. A handful of trades proves nothing.
Win rate and average win to lossTogether they show how the edge is made. Neither means much alone.
Sharpe ratioReturn per unit of volatility, for comparing strategies on one scale.
Out of sample resultHow the rules did on data the optimization never saw.

Why do backtests lie?

Most backtests look better than live trading for four reasons. Each one can be checked for.

  • Lookahead bias: the strategy uses a price it could not have known yet, such as the close of the bar it trades on.
  • Overfitting: parameters tuned until they fit the noise of one period. See overfitting and lookahead bias.
  • Missing costs: no spread, no commission, no swap. A scalping strategy can turn from profit to loss on costs alone. See spread, commission and swap.
  • Coarse data: on bar data the engine cannot know whether the stop or the target was hit first inside the bar. Tick data settles it.

How do you backtest in the Orion Quant Technologies Engine?

The Orion Quant Technologies Engine is a backtesting engine for forex, metals, indices, crypto, equities and CFDs. You write the strategy in Python, C#, Pine Script or visual blocks, or describe the rules in plain language and the AI assistant writes it. Validate checks the code before the run.

Market data comes from our own archive: minute bars and every tick with institutional bid and ask. Each run records which fill tier it used, OHLC, minute bars or ticks, and costs are fields: spread, commission per lot and side, and swap with the triple rollover on Wednesdays. After the run an audit grades it from A to F and checks it against prop firm rules. The engine is in early access through the waitlist.

Frequently asked questions

Is backtesting reliable?

A backtest is reliable when it uses realistic data, charges real costs, avoids lookahead and holds up on data it was not tuned on. Even then it shows how a strategy behaved in the past, not what it will earn. Treat it as a filter that rejects bad ideas.

How much historical data do I need for a backtest?

Enough for a few hundred trades across different market conditions. For an intraday strategy that is often two to five years; for a daily strategy, ten or more. Fewer than about a hundred trades is too small a sample to judge.

What is the difference between backtesting and paper trading?

Backtesting runs the strategy over the past in seconds or minutes. Paper trading runs it on live prices as they arrive, without real orders, and shows how it behaves on data that did not exist when you wrote it.

Can I backtest without coding?

Yes. In the Orion Quant Technologies Engine you can build a strategy from visual blocks or describe it in plain language to the AI assistant, which writes the code and validates it before the run.

Research and testing only. A backtest shows how rules behaved in the past, not what they will earn. Nothing here is investment advice.

Orion Quant Technologies