How do you backtest a crypto futures strategy?

To backtest a crypto perpetual futures strategy, write the rules first, replay past candles using only data that existed at each moment, record every trade in R, and subtract fees, funding, and slippage from each result. Tune the rules on one block of history (in-sample), then run the frozen rules once on candles they never saw (out-of-sample). A backtest is evidence about the past, not a forecast. Past performance does not guarantee future results. Leveraged futures carry a high risk of loss.

What does a futures backtest actually measure?

A backtest measures how a written rule set would have behaved on past perpetual futures data: how many trades it took, the R-multiple of each, the largest losing streak, and the deepest equity drop. It does not measure your ability to follow the rules live, and it cannot see future liquidity or volatility. If the rules are not written down yet, start with how to build a crypto futures strategy.

Why count fees, funding, and slippage in R?

A perp trade has costs a chart does not show:

  • Trading fees on entry and exit (venue schedules differ; read your exchange's fee page).
  • Funding payments for every funding time the position is held through, paid or received depending on side and rate — see how funding rates work.
  • Slippage: the gap between the price your rule wanted and the fill, largest on stop-market exits in fast moves.

Convert them into R so they sit on the same scale as the result. If 1R = 10 USDT and fees, funding, and slippage together cost 1.5 USDT on a trade, that trade's cost is 1.5 / 10 = 0.15R. A +2R winner becomes +1.85R and a −1R loser becomes −1.15R. A strategy with a thin edge can turn negative once costs are subtracted.

What is look-ahead bias and how do you avoid it?

Look-ahead bias means the test used information that was not available at the moment of the decision. Common leaks:

  • Signalling on a candle's close but filling at that same candle's open.
  • Indicators or levels computed with later candles (for example, a swing high that is only confirmed bars later).
  • Assuming the best order of events inside one candle. If a single candle touched both your stop and your target, the candle alone does not tell you which came first. Count the stop.

Fix: act on the next candle after a signal closes, compute every value from data up to that point only, and resolve ambiguous candles against yourself.

What is overfitting in a trading backtest?

Overfitting is tuning rules until they fit the noise of one data set. Signs: many parameters, very specific values (an RSI of 27 instead of 30), results that collapse when a value moves slightly, or a rule added only to remove one losing trade. The cure is fewer rules, round parameter values, and a test on data the tuning never touched.

How do in-sample and out-of-sample data work?

Split the history before you look at results:

  1. In-sample: the earlier block (for example the first two-thirds of the candles). Build and tune here.
  2. Out-of-sample: the later block you keep untouched. Run the frozen rules on it once.

If the out-of-sample result is much worse than in-sample, the rules were probably fitted to noise. Re-tuning after peeking at out-of-sample turns it into in-sample. After that, forward-test on a demo account before risking live margin.

How do you backtest a perpetual futures strategy step by step?

  1. Write the rules. Setup, entry trigger, stop-loss, exit, and risk per trade, in words a stranger could follow.
  2. Fix the data and the split. Choose the perpetual pair, timeframe, and date range, and mark the in-sample and out-of-sample blocks before testing.
  3. Replay candle by candle. Use only data available at each moment and enter on the next candle after a signal closes.
  4. Record every trade in R. Log entry, stop, exit, and R-multiple for each trade, winners and losers alike.
  5. Subtract costs. Take fees, funding, and slippage off each trade in R, and count the stop when a candle touched both stop and target.
  6. Tune in-sample only. Change rules using in-sample results, keep parameters few and round, then freeze them.
  7. Run out-of-sample once, then forward-test. Test the frozen rules on the untouched block, then on a demo account before going live.

What does a worked backtest example look like?

Illustration only; the numbers are teaching placeholders. Rules risk 1R = 10 USDT per trade, target +2R, stop −1R, costs 0.15R per trade.

  1. In-sample, 40 trades: 16 winners and 24 losers. Before costs: 16 × 2 − 24 × 1 = +8R, which is 8 / 40 = +0.2R per trade.
  2. After costs: 16 × 1.85 − 24 × 1.15 = 29.6 − 27.6 = +2.0R, which is +0.05R per trade. Costs took three-quarters of the edge.
  3. Out-of-sample, 20 trades, rules frozen: 6 winners and 14 losers. Before costs: 6 × 2 − 14 × 1 = −2R. After costs: 6 × 1.85 − 14 × 1.15 = 11.1 − 16.1 = −5.0R, or −0.25R per trade.
  4. Reading: the in-sample edge did not hold on unseen data. The honest result is "no edge yet", not "tweak until green".

Past performance does not guarantee future results. Leveraged futures carry a high risk of loss.

How does Tradeture fit into backtesting?

On Tradeture, strategies are backtested over 1000 candles, and bots trade with the same entry and exit settings as the Backtest page. Guests can open Bot Settings to test strategy parameters and risk per trade before connecting a key, and demo mode lets you forward-test without live margin. Whatever tool runs the test, the same rules apply: costs in R, no look-ahead, and a check on data the rules were not tuned on. Mtrader then applies risk per trade with automatic position sizing and an automatic journal through a trade-only API key; funds stay on the exchange. See also what is a crypto futures trading bot.

What are the short answers on backtesting?

What is backtesting in crypto futures trading?

Backtesting replays a written rule set on past perpetual futures candles to see how it would have traded, recording each trade in R after fees, funding, and slippage. It describes the past and does not guarantee future results.

How many trades does a backtest need?

There is no magic number. A handful of trades says little because a few lucky results can dominate. More trades across different market conditions, plus an out-of-sample block, give a fairer picture.

What is look-ahead bias?

Look-ahead bias is using information that did not exist at the decision time, such as filling at the open of the candle whose close created the signal. Enter on the next candle and compute values only from past data.

How do I avoid overfitting a strategy?

Use few rules with round parameter values, tune only on in-sample data, and run the frozen rules once on out-of-sample data. If results collapse when a value moves slightly, the rules are likely fitted to noise.

Should I include funding in a perpetual futures backtest?

Yes. Funding is paid or received at each funding time while a position is open, so strategies that hold through several funding times should subtract or add it per trade in R, along with fees and slippage.

Last reviewed by Ric Mescallado