How to backtest a crypto trading strategy
Backtesting runs your crypto strategy rules on past price data before you risk money. Write exact rules, add costs and slippage, then validate on new data.

On this page
- Use only data available at each trade's time.
- Include applicable costs, such as fees and slippage.
- Validate on out-of-sample data and keep a dated log.
- A profitable backtest does not guarantee future profits.
Backtesting a crypto trading strategy means running its rules on past price data to see if they worked. You will gather clean data, write exact rules and test them on a spreadsheet or a backtesting tool.
What you need before backtesting
You need clean historical crypto price data and a way to run the rules on it. Gather price and volume records for the pair and time frame you plan to test.
How do you backtest a crypto strategy?
Write your rules before you run any test. Decide entry, exit, position size and cost assumptions in advance.
- 1Write exact rulesState the conditions for every entry and exit. Set the position size and the costs you will subtract.
- 2Check data timingUse only the data available at the moment of each trade. Do not use a later candle to trigger an earlier entry.
- 3Set cost assumptionsAdd exchange fees and slippage to every trade. If you test perpetual futures, include funding costs too.
- 4Run and logApply the rules to the historical data and save the simulated gains and losses. Write down the number of trades, the largest loss and the total costs.
- 5Test on new dataRun the same rules on a separate period you did not use to build them. If the results fall apart, the rules are likely overfitted.
What should you do after backtesting?
Compare the simulated results with the risks you are willing to take before you trade real money. Keep a dated log of every test. If you later trade, the IRS treats crypto as property, so you may need records for taxes.
Frequently asked questions
Use enough data to cover more than one market condition, such as a rising and a falling market. Clean data over a shorter period beats messy data over a longer one.
Overfitting is when you tweak the rules until the backtest looks perfect. You spot it when the rules fail on data you did not use to build them.
Yes. You can use public historical price data and a spreadsheet or a backtesting tool. You do not need to share your exchange login or API keys.






