Explainer
How to backtest a futures strategy
Write rules that cannot be misread, run them on 1-minute data with costs, hold some months back, read every trade, then change one thing at a time.
Updated
The six steps
There are six steps, in this order: write the rules, get the data, set the costs, hold some months back, read every trade, and change one thing at a time. Each step has a way to go wrong. Each is covered below.
Step 1: Write the rules so they cannot be misread
Write each rule as a sentence with one reading. Name the market, the time zone, the bar size, the entry trigger, where the stop goes, where the target goes, and when the trade closes if neither is hit.
Then test each sentence against the awkward cases. Does a range include its last minute? Does a target fill when price touches it, or only when a bar closes beyond it? What happens when a bar opens already beyond your stop? In our method a range written as 18:00–19:00 ET includes both ends, which is 61 one-minute bars. A target fills on touch, at the exact price. A trade whose entry bar opens beyond the stop or the target is skipped, and the report lists it as skipped.
- Entry window
- How long a setup keeps waiting for its entry condition after the trigger. It counts from the close of the trigger bar.
- Max hold
- How long a position stays open once filled. It counts from the fill, not from the trigger.
- Time stop
- An exit at a fixed time. A time stop at 17:00 exits at the close of the 16:59 bar, the last bar that finishes before the stated time.
If two people could read a rule differently, it is not finished.
Step 2: Get data that matches the rules
Use bars no coarser than the rules need. An opening-range rule needs intraday bars. A rule about the daily close can use daily bars. Run the simulation on raw, unadjusted prices, and handle contract rolls as explicit events. If a back-adjusted series is used at all, use it only to draw charts.
Step 3: Set the costs
Add commission and slippage before the first run, not after. Commission is a flat amount per contract per side. Slippage is the number of ticks you assume you give up on each fill.
Commissions and fees vary by broker; a backtest should use your own. Costs are applied after the run, so they do not move fills, stops or targets.
Step 4: Hold some months back
Before you look at results, set aside part of the history and do not use it while you build the rules. Test the finished rules on those months once. Spread the held-back months across the whole history rather than cutting one block off the end, so the test covers different market conditions.
In our service, about 30% of months, spread across every year, are held back for each strategy. A trade that is open in a held-back month is dropped from the results.
Step 5: Read every trade
Do not stop at the summary figures. Open the trades. Check a few against the chart by hand. Look at trades near contract rolls, near the session open and near time stops, and at trades that bunch up in a few weeks.
If a trade surprises you, find out why before you trust the totals. You get every trade back with the exact rules and assumptions that were tested, so each one can be checked.
Step 6: Change one thing and test again
Change one rule per run: the stop distance, or the entry time, or the target. Run it again and compare. If you change three things at once, you cannot tell which one moved the result.
Keep a note of what each run changed. In our service each run of a strategy is a version, and the versions of a strategy are kept together, so the history of changes stays attached to it.
Questions and answers
What do I need before I start backtesting?
Written rules with one reading each, price data fine enough for those rules, a cost assumption, and a plan for which months to hold back.
How much history should I use?
As much as the data covers for the market you trade, so the test spans different conditions. On our data, NQ and ES start on June 2, 2016, and a run cannot ask for more history than the data holds.
Should I add costs before or after the first run?
Before. A first run without costs shows a result that no account could have had.
How do I find a mistake in a backtest?
Read the trades. Compare a few against the chart by hand, and check the ones near contract rolls, session opens and time stops.
Can I backtest without coding?
Yes, with our service. Describe your rules the way you would explain them to another trader. If something is ambiguous, we ask rather than guess.