How to backtest a crypto strategy, step by step
To backtest a crypto strategy, write the rule as one unambiguous sentence, run it over historical candles on the timeframe you will actually trade, include estimated fees and slippage, then read expectancy, profit factor, drawdown and trade count before looking at profit. Stress test it, then paper trade it on live prices. A backtest simulates the past and does not predict the future.
Key takeaways
- A backtest answers one narrow question: was this rule coherent on this history? It does not forecast.
- Write the rule down first. If you cannot state it in a sentence, it is not ready to test.
- Include fees and slippage. Leaving them out is the most common reason a backtest flatters a strategy.
- Read trade count, expectancy, profit factor and drawdown before profit.
- Stress test the result, then paper trade it. The gap between the two is the real measure of the simulation.
What do you need before you start?
Three things, and none of them is software. First, a rule you can state without hedging: when to enter, when to exit, how large to trade and what happens if you are wrong. Second, a market and timeframe you actually intend to trade, since results do not transfer between them. Third, an honest expectation that most ideas will fail the test, which is the point of testing them.
If you are new to the vocabulary, the glossary defines every metric used below, including expectancy, profit factor and drawdown.
Step 1: Write the rule as one sentence
“Buy dips in an uptrend” is not a rule. “Buy when price closes below the 20-period average while the 200-period average is rising, risk 1% of capital, place the stop 2% below entry, and exit at twice the risk” is. The difference is that the second can be evaluated the same way by a person, a spreadsheet or a program, and the first cannot.
This step does more work than any other. Every vague word in your rule is a decision you will end up making after you have seen the results, which is how people fool themselves. If the rule uses discretionary ideas such as order blocks or liquidity sweeps, it still has to be reduced to explicit numbers before it can be tested. See how AKQX turns those concepts into testable rules.
Step 2: Choose the market, timeframe and period
Pick the instrument and the candle size you would really trade. A rule tested on 1-hour candles tells you little about the same rule on 5-minute candles: noise, costs and the number of trades all change. AKQX backtests run from 1 minute to 1 day, and a free account runs one symbol and one timeframe per backtest.
Choose a period long enough to include more than one kind of market: a rise, a fall and a stretch of sideways movement. A strategy tested only through one rally has only demonstrated that it works in a rally. Crypto is especially prone to this, because a single large trend can dominate years of data.
Step 3: Set realistic costs
This is where most amateur backtests go wrong. Every trade costs a trading fee and suffers some slippage, and both come out of the result. A cost-free simulation is not a neutral starting point. It is systematically optimistic, and the error grows with how often the strategy trades.
Consider the arithmetic. If a strategy earns an average of 0.15% per trade before costs and each round trip costs 0.10% in fees and slippage together, two thirds of the edge is gone before any risk is taken. A strategy aiming for small gains per trade can sit on the wrong side of that line without anyone noticing.
AKQX deducts estimated fees and slippage from every simulated trade. They are estimates, not your exchange's exact schedule, so check your own fee tier and test with a deliberately pessimistic assumption as well.
Step 4: Run it and check the trade count first
Before any profit figure, look at how many trades the test produced. A result from a handful of trades is indistinguishable from luck, however good it looks. AKQX rejects a crypto result with fewer than 100 trades for exactly this reason.
Then check that the trades are spread through the period rather than bunched into one stretch. A strategy whose entire result came from three weeks in a ten-month test has a story about three weeks, not about ten months.
Step 5: Read the report in the right order
Profit is the least informative number on the page. Read in this order instead:
- Trade count, as above.
- Expectancy: the average result per trade. Zero or negative means there is no edge, whatever the win rate says.
- Profit factor: gross wins divided by gross losses. Below 1.0 the losses outweighed the wins.
- Maximum drawdown: the deepest fall from a peak. This decides whether the strategy is survivable, because nobody keeps trading through a fall they cannot tolerate.
- Win rate, average win and average loss, together. A high win rate with large losses is fragile.
- MAE and MFE: how far trades moved against you before working, and in your favour before you exited. They show whether stops are too tight or targets leave gains behind.
- Net profit, last.
AKQX also scores the result out of 350 points and rejects it automatically if expectancy is zero or negative, if profit factor is below 1.0, or if maximum drawdown exceeds 30 percent. The full list is on the methodology page.
Step 6: Try to break it
A result that survives only in its original form has not been tested, it has been admired. Three checks are worth doing:
- Nudge the parameters. Change a setting slightly and rerun. If the result collapses, you found a value fitted to noise. A real edge degrades gradually near its best setting rather than falling off a cliff.
- Test unseen data. Walk-forward testing tunes on one slice of history and evaluates on the next. If it is positive on most unseen slices, the edge is less likely to be an accident.
- Resample the outcomes. A Monte Carlo check reorders the same trades many times to see how bad the worst runs could have been. AKQX uses 1,000 simulations and treats a 30% fall from peak as ruin.
The enemy throughout is overfitting: tuning a strategy so closely to past data that it captures that history's noise. Every filter you add makes the curve prettier and the strategy less likely to survive anything new.
Step 7: Paper trade it before anything else
A backtest replays finished candles and assumes a fill. Live markets hand you half-formed candles, spreads that widen, and orders that are rejected. Paper trading runs the same rules forward on live prices with virtual money, so those effects show up without costing anything.
The most useful output is the drift: the gap between what the backtest predicted and what the rules actually did. A small, explicable drift is encouraging. A large one usually means the backtest was flattering the strategy, and the honest response is to go back to the rules, not forward to real money.
A worked example, with made-up numbers
Illustrative only. A trader backtests a breakout rule on 1-hour candles and gets 140 simulated trades, a win rate of 38%, an average win of 2.6 units and an average loss of 1.0 unit.
Expectancy is 0.38 × 2.6 minus 0.62 × 1.0, which is 0.988 minus 0.62, so about 0.37 units per trade before costs. If fees and slippage take 0.15 units per trade, expectancy falls to roughly 0.22. That is still positive, but it is less than 60% of the headline figure. If the costs had been 0.40 units, the strategy would have had no edge at all, and a cost-free test would never have shown it.
The next questions are the ones from Step 6: does it survive a slightly different breakout length, is it positive on data it was not tuned on, and how deep was the worst drawdown? Only then does it earn a paper trading run.
The mistakes that waste the most time
- Leaving costs out, then being puzzled when live results are worse.
- Tuning until it looks good, which fits the past instead of finding a behaviour.
- Look-ahead bias: a rule that quietly uses information not available at the moment of the decision, such as a candle's close while that candle is still forming.
- Testing on one market regime, usually the most recent one.
- Treating profit as an expected return. It is the output of one simulation.
- Skipping paper trading because the backtest was convincing.
A reminder about what this is. AKQX is software only. It is not a SEBI-registered Investment Adviser or Research Analyst and gives no investment advice. Backtest and paper-trading results are simulated and do not guarantee future results. Crypto products are unregulated and can be highly risky, and there may be no regulatory recourse for any loss.
Questions about how to backtest a crypto strategy
How many trades do I need for a backtest to mean anything?
As a rough floor, AKQX rejects a result with fewer than 100 trades for crypto, because below that an edge cannot be told apart from luck. More is better, and the trades should be spread across different market conditions rather than clustered in one trend.
Should I include fees and slippage in a crypto backtest?
Yes, always. A cost-free backtest is systematically optimistic, and the error grows with how often the strategy trades. A strategy earning a small amount per trade can look profitable before costs and clearly unprofitable after them.
What timeframe should I backtest on?
The one you intend to trade. A rule tested on 1-hour candles says nothing reliable about the same rule on 5-minute candles, because noise, costs and the number of trades all change. AKQX supports 1 minute to 1 day.
How long a period should I test?
Long enough to include more than one kind of market: a trend up, a trend down and a stretch of sideways movement. A strategy tested only on one rally has only proved it works in a rally.
Is a profitable backtest a reason to start trading with real money?
No. It is a reason to run the next check, which is paper trading on live prices. A backtest is a simulation of one past under one set of assumptions, and live trading meets spreads, rejections and delays that history does not contain.
What does it mean if my backtest result is very good?
Treat it as a prompt for suspicion before celebration. Unusually good results are more often caused by overfitting, look-ahead bias or missing costs than by a genuinely exceptional strategy. Test a nearby parameter value and see whether the result survives.
Keep reading
Run your first backtest free
A free account includes 10 backtests a month, one symbol and one timeframe per run, with no card and no exchange connection.