How to backtest a crypto strategy honestly
Short answer
Write the rules down exactly (when to buy, how much, when to sell), test them on several years of real daily prices with a fee and slippage on every trade, keep the last part of the period aside as an out-of-sample test, and compare the result and the worst drop with simply buying and holding. A strategy that only wins in the period you tuned it on, or that loses to buy-and-hold after fees, is not one to trust.
- Write the rules so a computer could follow them: entry, size, exit.
- Use daily closes for at least 2 years, ideally through a crash.
- Charge a fee (e.g. 0.1%) and slippage (e.g. 0.05%) on every fill.
- Tune on the first 70% of the period; judge on the last 30%.
- Compare with buy-and-hold and look at the worst drop, not only the return.
- Paper-trade it on live prices before using money.
Copy-paste code
The timing rule that avoids look-ahead
decide at the CLOSE of day i -> fill at the OPEN of day i+1
fill price (buy) = open * (1 + slippage)
units bought = amount * (1 - fee) / fill priceGood to know
A backtest describes the past; past results don't guarantee future results.
The more settings you try, the more likely the best one is luck: check it out of sample.
Information only, not financial advice.
Backlark: Test a crypto strategy before you trust it
from $9/monthBacklark does all of this with no code: six strategy types, fees and slippage by default, an out-of-sample split, buy-and-hold and the worst drop beside every result, then a paper bot with alerts. Free for BTC and ETH; Pro $9 a month.
Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)Questions
How many years of data do I need?
Enough to include at least one big fall and one rise; for Bitcoin that means several years of daily closes.
Why compare with buy-and-hold?
Because doing nothing is the free alternative. A strategy that trades a lot and ends below buy-and-hold after fees costs you money and attention.
Free: the Free Planner Sampler
4 printable previews (budget, debt payoff, focus planner, habit tracker), then 5 short emails with formulas that make a budget stick.