What is backtesting?

By Oalgo · Last reviewed

Backtesting means running your rules on past prices, as if you had followed them at the time. You see where each trade would have opened and closed, and how the whole set of rules behaved over the period you chose.

How does a backtest work?

#
Diagram: past prices go through your rules, which produce simulated trades and a report.Past pricesYour rulesSimulated tradesReport
A backtest replays the past. Nothing is bought or sold.
  • Pick a market, a timeframe and a date range.
  • Write your rules: when to enter, when to exit, and how much to use each time.
  • The test steps through the prices one candle at a time and applies your rules, using only the data that existed at that moment.
  • At the end you get a backtest report and a chart of every simulated trade.

What does a backtest report show?

#
NumberWhat it tells you
TradesHow many times your rules entered and exited.
Win rateThe share of trades that ended above their starting value, after fees.
DrawdownThe largest fall from a high point before a new high was reached.
FeesWhat the trades would have cost, so the numbers stay realistic.

What a backtest cannot tell you

#
  • The past does not repeat exactly. Rules that behaved well before can behave badly later.
  • Rules tuned too closely to one period, called overfitting, often fail on the next one. Test on more than one date range.
  • Real fills can differ from the test, especially when prices move fast.

That is why the next step is a forward test: the same rules on new prices, as they arrive.

In Oalgo you can test your idea without writing code: tell Oalgo AI your idea in your own words, check the rules it builds, then run the backtest. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.

Read next