How to backtest a crypto trading strategy

By Algonney team · Updated

A backtest runs a trading strategy on historical market data and shows what it would have done, trade by trade. Done well, it is the cheapest way to find out that an idea does not work. Done badly, it produces a beautiful equity curve that falls apart the day real money is involved. This guide walks through a backtest from start to finish, using Algonney as the example.

Step 1: write the strategy as exact rules

A computer cannot test "buy when it looks strong". Every part of the strategy needs a precise rule:

  • Timeframe: the candle size the strategy evaluates on.
  • Entry: the exact condition, for example "the close crosses above the upper Bollinger Band while ADX is rising".
  • Stop loss: where the trade is wrong. On Algonney a strategy cannot be saved without one.
  • Take profit or exit: a target, a trailing stop, a time exit or an exit rule.
  • Side: long, short or both.

You can describe this in plain words to Jarvis, the AI assistant, which turns it into rules and asks about anything missing. See the crypto strategy builder.

Step 2: choose what to test on

On Algonney you start a backtest from the chat: tell Jarvis what to test, or open a saved strategy and choose Backtest. Decide:

  • Exchange and market. Fees, order steps and leverage rules differ between exchanges and between spot and futures. Test as the exchange you will trade on. Algonney's history comes from Binance's public data, and a backtest can test as any supported exchange with its own fees and trading rules.
  • Symbols. A rule that works on one coin may be luck. Test several.
  • Date range. Include rising, falling and sideways markets.
  • Capital, sizing and leverage. Use the sizing you would use live.

Your plan sets how many backtests you can run and how large each can be:

LimitFreeStarterProMax
Backtests per day5 backtests100 backtests200 backtests400 backtests
Coins per backtest1 coin2 coins5 coins10 coins
Longest backtest90 daysno limitno limitno limit
Backtest history90 daysno limitno limitno limit

Step 3: include every cost

Costs are where most backtests lie. Every trade pays a fee on entry and exit, and market orders fill at a slightly worse price than the last trade: that is slippage. On perpetual futures, open positions also pay or receive funding. A strategy that trades often can turn from profit to loss on costs alone.

On Algonney, fees and slippage start from the exchange's values and can never go below a floor, so a test cannot assume trading is free:

CostValue
Lowest fee rate0.02%
Lowest slippage0.01%
Default slippage (perpetuals)0.03%
Default slippage (spot)0.05%
Default half spread0.01%

Funding is applied at each funding time on futures, and liquidation is checked on every bar.

Step 4: run it honestly

Two details decide whether a backtest is honest:

  • No look-ahead. A signal can only use candles that have closed. On Algonney a signal on a closed bar fills at the next bar's open, with slippage.
  • Order inside the candle. When both the stop loss and the take profit fall inside one candle, a test that assumes the target came first flatters the result. The engine reads one-minute candles inside the bar to see which was hit first.

Before you start, you see the run's cost in platform tokens and your place in the queue.

Step 5: read the results, not just the total

The result shows key metrics, the list of trades, the equity curve, drawdown and monthly returns. Look at:

  • Number of trades. A handful of trades proves little.
  • Maximum drawdown. The largest fall from a peak. Ask whether you would keep the bot running through it.
  • Losing streaks. How many losses in a row, and what they cost.
  • Average win and loss in R, the distance between entry and stop. A strategy can win rarely and still work if winners are large.
  • Costs. Fees and funding paid compared with the profit.
  • Skipped signals. Signals the engine did not trade, counted by reason.

Open individual trades. Each shows its entry and exit reason, the indicator values at that bar, the fees and funding, and is drawn on the chart. A proof box lists the data source, the exchange rules and fees used, the engine version and a data hash, so the same inputs always give the same result.

Step 6: guard against overfitting

If you tweak a strategy until the backtest looks perfect, you have fitted it to the past. To check:

  • test the final version on a period you did not use while building it;
  • test it on other symbols;
  • prefer simple rules with few settings;
  • be suspicious of results that change a lot when a setting moves a little.

Read more in Why your backtest lies.

Step 7: paper trade before going live

A backtest is a test on the past. A paper bot runs the same strategy on live prices with virtual USDT, on the same engine as a live bot. Compare its trades with what the backtest expected. Only then consider live trading.

The backtesting guide in the docs shows each screen in the app, and Backtesting summarises the feature. Plans are on Plans and pricing.

A good backtest reduces surprises; it does not remove risk. Read the risk disclosure before you trade live.

Past results do not guarantee future returns.

Questions and answers

How do I backtest a crypto trading strategy?

Write the strategy as exact rules, choose the exchange, market, symbols, timeframe and date range, include realistic fees, slippage and funding, run it on real historical candles, then read every trade, not only the total. Finally run it on paper with live prices before you use real money.

How much historical data do I need for a backtest?

Enough to include different market conditions: rising, falling and sideways markets, and calm and volatile periods. A strategy tested only on one strong trend tells you little about the next sideways month. Your plan sets the longest range you can test at once.

What is a good backtest result?

One you can trust, more than one with a high return. Look for enough trades to mean something, a drawdown you could live through, results that hold on other symbols and periods, and profits that survive fees and slippage. A smooth curve built on a handful of trades is a warning sign.

Why are backtest results different from live trading?

Live trading has real fills, partial fills, delays, changing spreads and funding that no test reproduces exactly. A backtest also cannot know the future: a strategy fitted closely to the past often does worse afterwards. Paper trading on live prices shows the difference before real money is at stake.

Can I backtest a crypto strategy for free?

Yes. The free plan includes a number of backtests per day within its limits, and no exchange key is needed. Backtests are paid with platform tokens and you see the cost before each run.