Backtest

A backtest is a check of a trading strategy on historical data: the entry and exit rules are run over past candles to see what the return, drawdown and number of trades would have been. It shows how the strategy behaved before, but does not promise the same in the future.

How a backtest is run

First the strategy is written down as precise rules, with no “depending on the situation”: when to enter, where to put the stop and target, what size to trade, when to exit. Then you pick a coin, a timeframe and a stretch of history, ideally covering different market phases: rallies, declines and sideways periods. The program walks through the candles in order and executes trades as if trading were live. Checking by hand with screenshots does not work, because the eye picks the good examples. You can also test a strategy in the free terminal on this site: the rules are written as a script and the result appears below the chart.

Which numbers to look at

The total return is only the start. What matters is the maximum drawdown, the deepest fall of the account from a peak, plus the number of trades, the win rate, the average profit and average loss, and the profit factor, the ratio of gross profits to gross losses. It helps to compare the result with simply holding the same coin over the same period: many complex strategies lose to plain buy-and-hold in a rising market. If there are fewer than a few dozen trades, the conclusions are unreliable, since the result may be down to chance.

The main traps

Overfitting: after trying hundreds of setting combinations, it is easy to find ones that are perfect for the past but fail on new data. Look-ahead bias: a rule accidentally uses information that was not available at the time of the trade, such as the close of the very candle it “entered” on; an honest tester executes a closed candle's signal no earlier than the next candle. Unrealistic execution: without fees, slippage and funding, the strategy looks better than it is. Survivorship bias: history keeps the coins that survived, while hundreds of vanished tokens, on which the strategy would have lost, never make it into the data.

How to test more honestly

Split the history in two: tune the settings on the first part and judge the result on the second, which the strategy has never seen. Test on several coins and timeframes, because a rule that works on only one chart is probably overfitted. Build in fees and slippage with a margin. After the backtest, run the strategy on a demo account or with a small amount, as the live market will show what history does not. A good backtest does not promise profit; it only weeds out clearly bad ideas. This is not investment advice.

Example

A trader tests the rule “buy when the price closes above the 50-day average, sell when it closes below” on a hypothetical coin over four years. Without fees the result is plus 180%; with 0.1% fees and slippage it is plus 120%, with a maximum drawdown of 45% across 38 trades. Simply holding over the same period returned plus 150% with a 75% drawdown.

Related terms

Algorithmic TradingWin rateDrawdownDemo tradingTrading botSharpe Ratio

On the site

TradingFutures calculatorOptions levelsHyperliquid

This article was written by AI. Check specific rates, taxes and broker terms with primary sources.

↑ Top