Backtest Fill Assumptions: Why Next-Bar-Open Fills Matter

Backtest fill assumptions decide which prices your trades get. Compare same-bar close, next-bar open and intrabar fills, with worked examples of the gap.

Trigr Research6 min read
On this page
  1. What is a fill assumption?
  2. What are the common fill conventions?
  3. Why is filling at the signal bar's close a problem?
  4. How should a backtest handle stops and targets inside a bar?
  5. When does the gap between bars matter most?
  6. How do fills compare between backtest, paper and live?
  7. A quick audit for any backtest's fills
  8. Next steps

TL;DR: A fill assumption is the rule a backtester uses to decide which price each trade gets. Filling at the close of the bar that produced the signal is subtly impossible, because that close is only known once it can no longer be traded; the next bar's open is the earliest honest price. Intrabar rules matter just as much: when a take-profit and stop-loss share a candle, an optimistic tie-break can turn a mediocre strategy into an apparently excellent one.

What is a fill assumption?

A backtest works on bars: open, high, low and close for each time step. Your strategy decides something from those bars, and the simulator must then answer a practical question: at what price did the order execute?

That answer is the fill assumption. It is rarely shown in a results screen, yet it shapes every trade in the log. Two strategies with identical signals can produce visibly different equity curves under different fill rules.

Fill assumptions are part of the broader discipline of point-in-time backtesting: the simulation may only use information and prices that existed at the moment of each decision.

What are the common fill conventions?

Convention Price used Honest? Typical effect
Signal-bar close The close that generated the signal No; that price is gone when the signal is known Flatters most strategies slightly, some a lot
Next-bar open The first price after the signal Yes, as a baseline Small cost per trade in 24/7 markets
Next-bar close The close one bar later Yes, but adds a full bar of delay Overstates delay for fast strategies
Limit at level A resting order's exact price Only if touch implies fill and the order was placed in time Can overstate fills on thin books
Intrabar best case The favorable extreme of the bar No Large, systematic overstatement

TradingView's Pine Script documentation on strategy order fills describes the same principle for its default broker emulator: an order placed when a bar closes fills at the open of the following bar, because creating and filling an order on the same tick is unrealistic.

Trigr's Studio backtests fill signals at the next bar's open. Exits driven by signals, such as a signal flip, follow the same rule: the flip is read at the bar's close and the position closes at the next open. Time stops are the exception; they close at the close of the bar where the limit is reached.

Why is filling at the signal bar's close a problem?

Consider a 1H strategy that buys when the close finishes above a moving average. At 13:59:59 you do not yet know the close. At 14:00:00 you know it, but that bar is over. The first price you can trade is the 14:00 bar's open, plus whatever latency your system adds.

In continuous crypto markets the next open is usually very close to the prior close, so the price difference per trade is often a few basis points or less. The problem is that it is not random. Signals tend to fire when price is moving, and a price that is moving at the close tends to keep moving for a moment afterwards.

A hypothetical illustration: a strategy makes 300 trades a year, and the next open is on average 2 basis points worse than the signal close at entry. That is 0.02% per trade, or about 6% of notional summed over the year, before any slippage. For a strategy whose gross edge is 0.10% per trade, the fill rule alone removes a fifth of it.

In a research notebook the fix is one line, applying the signal to the following bar before pricing the trade (the pandas shift method is the usual tool):

# signal is computed from bar t's close; trade at bar t+1's open
position = signal.shift(1)
entry_price = df["open"]

How should a backtest handle stops and targets inside a bar?

Take-profit and stop-loss exits create a different problem. They can trigger at any moment inside a bar, and a candle only tells you the extremes, not their order.

Suppose you are long at 100 with a take-profit at 102 and a stop-loss at 98. The next 4H candle has a high of 102.5 and a low of 97.5. Both levels were touched. Which came first?

  • If the simulator assumes the take-profit, the trade books +2%.
  • If it assumes the stop-loss, the trade books −2%.

Now imagine 200 trades, 12 of which land on ambiguous bars like this one. An optimistic rule books +24 percentage points of summed trade return on those 12; a conservative rule books −24. The 48-point swing comes entirely from an assumption, not from the market.

Tight exits on long timeframes make ambiguous bars more frequent, so this bias is largest for exactly the strategies that look most attractive: high win rate, small targets, coarse bars.

Trigr's intrabar rules

Trigr resolves these cases conservatively:

  • Finer data first. When the strategy's timeframe is coarser than 5 minutes, the engine replays the 5-minute candles inside the ambiguous bar and takes whichever level was touched first.
  • Stop wins on a tie. If finer data cannot decide, for example because a single 5-minute candle also contains both levels, or finer data is unavailable, the stop-loss wins.
  • Gaps fill at the open. If a bar opens beyond your stop, the stop fills at that worse open, as a real stop-market order would. A take-profit that is gapped through also fills at the open, which in that case is the better price.
  • Opening fills see the whole bar. A position opened at a bar's open participates in that same bar's stop and target checks, because the price path starts at the fill.

These rules can cost a strategy some backtested performance. That is intended: the goal is a result you are unlikely to beat by accident in live trading, not one you are likely to fall short of.

When does the gap between bars matter most?

In most crypto perps the next open sits inside the previous bar's range, so gap handling rarely changes anything. It matters more in three situations:

  • Volatility bursts. Liquidation cascades and news can move price several percent within seconds, so the first tradeable price after a signal can differ materially from the close.
  • Session-gapped history. Some TradFi price histories have gaps between sessions. On Trigr, TradFi markets via Hyperliquid HIP-3 can be backtested and run on paper agents in the current beta (not traded live); the gap-through rule means a stop crossed overnight fills at the worse open. With a stop at 98 and a next open at 96, the loss is 4%, not 2%.
  • Many small trades. Small per-trade differences compound across hundreds of trades, especially when combined with slippage and funding.

How do fills compare between backtest, paper and live?

No fill rule makes a backtest identical to live trading. Live orders face latency, partial fills and queue position, none of which a bar-based simulator sees. What a conservative rule gives you is a baseline that errs in the right direction.

Paper trading is the next check. Trigr's paper agents fill at the current Hyperliquid price and pay the base taker fee and the builder fee, with no slippage or funding modeled, and the agent view marks the frontier between the backtest and the forward record, so you can see whether live prices behave like the simulation. Our guide to paper trading a crypto bot covers how long to run that test and what to compare.

Backtests are not guarantees; perps are leveraged and can lose more than expected.

A quick audit for any backtest's fills

Before trusting a result, ask:

  1. At what price does an entry fill after its signal?
  2. What happens when a take-profit and stop-loss share a bar, and how many trades were affected?
  3. Does a stop that is gapped through fill at the level or at the gap price?
  4. Are exits on signals delayed the same way as entries?
  5. Does the trade log let you check a few fills by hand against the candles?

This article gives Trigr's answers to each of these, the backtesting docs cover the cost and intrabar rules, and every run includes a full trade log you can inspect.

Next steps

Open the trade log of a strategy with tight targets and look for trades that exit on bars where both levels were in range. If you are hunting for leaks beyond fills, read look-ahead bias in crypto backtests, or browse strategies with verified backtests on the Trigr marketplace.

Frequently asked questions

Why do backtests fill at the next bar's open?

Because a signal computed from a bar's close is only known once that bar has ended, when its close price is no longer tradeable. The next bar's open is the earliest realistic price at which an order sent after the signal could fill.

What happens when take-profit and stop-loss are hit in the same candle?

A candle does not record which level was touched first, so the backtester needs a rule. Trigr replays 5-minute candles inside the bar when the timeframe is coarser, and if that cannot decide, the stop-loss wins as the conservative outcome.

Does filling at the next open make much difference in crypto?

Per trade it is usually small, because 24/7 markets rarely gap between bars. It still matters for fast strategies with many trades, for signals that fire during sharp moves, and for any market whose price history has session gaps.

Put the idea to an honest test.

Describe a strategy in plain English or from your own AI assistant, backtest it on point-in-time data, and forward-test it on paper before any real money is involved.