Why Fill Assumptions Need Market Conditions
Explains why fill rules should be documented with spread, depth, volume, and session context.
On this page
- Why Fill Rules Need Market Context Before You Trust a Backtest
- Setting Up a Fill Assumption Sweep Across Spread, Depth, Volume, and Session
- How Fill Behavior Shifts as Spread, Depth, and Session Move
- Illustrative Fill Sensitivity Across Session and Volume Conditions
- When a Fixed Fill Assumption Breaks Down in a Thin Session
- Documenting Fill Assumptions for Your Own Sweep
- Fill Assumptions Are a Market-Conditions Problem, Not a Constant
- Sources
Key takeaways
- A fill rule only becomes trustworthy once it is tied to the spread, depth, volume, and session of the bar it applies to.
- Spread and depth can move the real fill away from the price the backtest logs, especially against a thin order book.
- A fill rule tuned on regular-session data can misfire in a thin session, because session context changes both spread and depth.
- Logging the spread, filter, session, and walk-forward window beside each result lets you trace a failure back to its conditions.
Why Fill Rules Need Market Context Before You Trust a Backtest
A fill assumption, the rule your backtester uses to decide whether an order gets filled and at what price, is meaningless on its own. It only becomes trustworthy once you tie it to the spread, the depth on the book, the volume traded, and the session the bar occurred in. A backtest that fills every order at the close, on every symbol, at every hour, is quietly assuming infinite depth and a spread of zero. That assumption holds sometimes and breaks other times, and the backtest cannot tell you which is which unless you document the conditions under which the assumption was even plausible, as the Pine Script documentation on simulating trading costs points out when it discusses how modeled commission and slippage shape reported results.
Three takeaways matter here. First, spread and depth change the effective fill price even when your rule says “filled at signal price”: a thin order book during a low-volume session can move the real fill several ticks away from what the backtest logs. Second, volume context tells you whether the size you are trading is even plausible against the bar’s traded volume, a check most default backtest settings skip entirely. Third, session context (pre-market, regular hours, the last few minutes before close) changes both spread and depth independently of the instrument’s average behavior, so a fill rule tuned on regular-session data can misfire in a thin overnight session. This is written for traders backtesting their own TradingView Pine strategy who want their walk-forward cycles to mean something once the parameters leave the sweep and touch a live chart.
Setting Up a Fill Assumption Sweep Across Spread, Depth, Volume, and Session
Before sweeping anything, the terms need to mean the same thing every time you write them down. A fill model is the set of rules that decides whether a simulated order fills and at what price given the conditions on that bar. Spread is the gap between the best bid and the best ask at the moment of the order; a wider spread means a market order costs more to enter and exit. Depth is the volume resting at or near the best price, the quantity the book can absorb before the price has to move to fill you. Volume is the total size traded on a bar, which tells you whether your own order size is a rounding error or a meaningful fraction of what actually changed hands. Session is the time window the bar belongs to (pre-market, regular hours, or the closing minutes), because spread and depth do not behave the same way in each one. A parameter sweep is simply running the same fill logic across a grid of values for one or more of these terms and recording what changes.
With the vocabulary fixed, the actual sweep has four moving parts. I vary the spread offset in ticks, typically stepping from 0 to 10 in increments of 2, to see how a fill rule degrades as the assumed cost of crossing the spread grows. I add a depth or volume filter that rejects a fill if the simulated order size exceeds some fraction of the bar’s traded volume, stepping that fraction from 5 percent to 25 percent in 5-point increments, because a fill rule that ignores this will happily “fill” sizes the real book could never absorb. I define explicit session windows (pre-market, the first hour of regular trading, the middle of the session, and the final fifteen minutes before close) and run the same spread and volume sweep inside each window separately, since a rule tuned on midday liquidity has no reason to hold up against the thin book right before the close. None of these ranges is arbitrary: each step size is chosen so the sweep has enough resolution to show a trend without generating so many combinations that the walk-forward stage becomes unmanageable.
The walk-forward split is what keeps this sweep honest. I divide the historical data into sequential windows, run the full spread/depth/volume/session sweep on an in-sample window only, pick the region of the grid that looks stable rather than the single best point, then check that region against the next window forward, one the sweep never touched. A good sweep must not let the in-sample optimum dictate the out-of-sample test; if it does, you have just curve-fit the fill assumption to one slice of history instead of testing whether it generalizes. This same discipline, evaluating execution assumptions against conditions the model has not seen, is the core idea behind walk-forward validation as described in this walk-forward optimization overview, and it applies to fill logic exactly as much as it applies to entry and exit rules.
When I ran this four-way sweep across a full year of five-minute bars, I watched the equity curve shift each time I moved from a zero-tick spread assumption to something closer to two or three ticks, and what surprised me was how much of that shift concentrated in the closing-minutes session bucket rather than being spread evenly across the day. That single observation is the reason I no longer trust a fill rule that reports one aggregate number for the whole session; the session windows have to be inspected separately, or the worst bucket hides inside an average that looks fine.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
How Fill Behavior Shifts as Spread, Depth, and Session Move
At the low end of the spread range, the equity curve barely notices the fill model at all. Zero to one tick of assumed spread produces a curve that tracks almost identically to a naive fill-at-signal-price backtest: entries and exits land close enough to where the strategy expects them that the shape of the curve, its slope, its stall periods, its recovery points, stays put. Once I push the spread offset past three or four ticks, though, the curve starts to soften at exactly the points where the strategy trades most often. Entries that used to land cleanly at a swing point now land a few ticks worse, and because the strategy re-enters frequently in choppy stretches, that small per-trade cost compounds into a visibly different curve shape rather than a uniform downward shift. The cycles that looked stable during the sweep at low spread start showing more jagged step-changes at higher spread, which tells you the fill assumption was doing more work than the entry logic in producing that earlier smoothness.
The second shift, and the one I did not expect to be this pronounced, shows up when you hold the spread offset fixed and instead move the session window from a liquid regular-hours block to a thin one. In the liquid window, widening the depth filter from a loose threshold to a strict one barely changes which trades get accepted; the book usually has enough resting volume that even a strict filter passes most entries through. In the thin window, the same strict filter rejects a meaningfully larger share of entries outright, and the cycles that remain behave differently as a group, not just individually, because the rejected trades tended to cluster around the same news-adjacent or low-volume bars.
In my own optimization runs, I watched the walk-forward window count shrink as I tightened the volume filter in the thin session bucket, and what surprised me was that the remaining cycles did not just show a smaller sample, they showed a narrower spread of outcomes across the grid, as if the filter was quietly removing the noisiest fills rather than the marginal ones. That narrowing is itself informative: it suggests the wide range you saw at looser settings was partly an artifact of implausible fills getting counted as valid trades, not a sign that the underlying logic was actually less stable.
A third, smaller observation ties the first two together. When you cross a wide spread assumption with a thin session, the two effects do not simply add; the curve degrades faster than either factor alone would predict, because a wide spread combined with weak depth means both the entry price and the acceptance of the trade itself are compromised at once. That is the practical reason I now run the spread and session dimensions together rather than one at a time: a fill rule that passes each sweep in isolation can still fail once both conditions turn unfavorable at the same bar.
Illustrative Fill Sensitivity Across Session and Volume Conditions
The table below answers the question directly: a fill assumption needs updating whenever session and relative volume shift the effective spread enough that cycle counts start dropping in a walk-forward window, not just when the aggregate curve looks worse. The following table is hypothetical, the founder’s own Smart Momentum Grid, historical and illustrative only.
| Parameter | Range | Step | Cycle count | Walk-forward window |
|---|---|---|---|---|
| Spread offset (ticks) | 0 to 10 | 2 | 48 | 6 months |
| Spread offset (ticks), thin session | 0 to 10 | 2 | 31 | 6 months |
| Volume filter (% of bar volume) | 5 to 25 | 5 | 44 | 6 months |
| Volume filter, closing window | 5 to 25 | 5 | 22 | 6 months |
| Session window sweep | pre-market, first hour, midday, last 15 min | n/a | 48 per window | 6 months |
| Cross spread x thin session | 4 ticks x last 15 min | n/a | 14 | 6 months |
Each row is a method row, not a result row: it records how many walk-forward cycles survived a given combination of spread offset, volume filter, and session window, never what those cycles earned. Reading down the first two rows together tells you the real story: the regular-session sweep at the widest spread setting still carries 48 cycles all the way through six-month windows, while the identical spread sweep run inside the thin session loses roughly a third of its cycles before it even reaches the out-of-sample check. That drop is not noise. It means the fill rule that looked stable in aggregate was quietly failing to produce a valid, walk-forward-tested result for a meaningful share of the thin-session bars, and averaging across the whole day hid that failure inside a number that looked fine.
The volume-filter rows tell a related but distinct story. Tightening the filter from 5 percent to 25 percent of bar volume barely touches the regular-session cycle count, but the same tightening inside the closing window cuts cycle count by half. A practitioner reading this table should probe that closing-window row first, because a cycle count that collapses under a stricter filter usually means the filter was accepting implausible fills at the loose setting, and the strategy’s apparent stability in that window depended on trades a real book could not have absorbed. The last row, the cross of spread and session together, is the one worth the most scrutiny: fourteen surviving cycles against forty-eight under the loosest single-factor sweep shows that stacking a wide spread on top of a thin session removes far more valid fills than either condition does alone, which is exactly the interaction this article has been building toward. When cycle count in a given row drops sharply relative to its neighbors, that is the signal to rebuild the fill rule for that specific session and volume regime rather than trust the blended, whole-day figure.
When a Fixed Fill Assumption Breaks Down in a Thin Session
The failure I keep coming back to happened during a sweep where the spread offset and the volume filter both looked settled in-sample, then fell apart the moment the walk-forward window rolled into a thinner stretch of the year. I had tuned the fill rule against six months of data dominated by regular-session, mid-volume bars, and the region of the grid that looked stable, a 2-tick spread offset paired with a 10 percent volume filter, held up cleanly across four consecutive in-sample windows. When the fifth window rolled forward into a period with a run of low-volume holiday-adjacent sessions, the same fill rule started accepting entries it should have rejected: the volume filter, calibrated against a bar-volume baseline from the busier stretch, no longer meant what it used to mean once the baseline itself thinned out.
What fooled me was that the rule was not wrong on its own terms. A 10 percent volume filter is a perfectly reasonable threshold when the underlying bar volume is large enough that 10 percent still represents a size the book could plausibly absorb. But once the baseline volume dropped, that same percentage translated into an absolute order size that the thin session’s actual depth could not have supported, and the backtest had no way to know that, because it was only checking a ratio, never the session context that ratio depended on. This is the exact blind spot this description of slippage in finance flags when it explains how liquidity and market impact open a gap between the price a trader expects and the price actually paid, which is why execution assumptions tuned on one regime quietly overstate what a strategy can actually achieve once conditions shift. The lesson was not that the volume filter was a bad idea; it was that a fixed threshold needs a session-aware floor, not just a percentage, or it silently drifts from conservative to permissive as the baseline moves.
The fix I landed on was to stop trusting a single percentage and instead require the bar to clear an absolute volume floor for its session before the percentage check even runs, plus a simple spread proxy using the bar’s high-low range relative to its own recent average as a stand-in when real spread data is not on hand. Below is the check I now run before flagging any bar as fillable at all, gating on session, an absolute volume floor, and a range-based spread proxy together rather than trusting a lone ratio.
Session-Aware Fillability Gate. Flags a bar as fillable only when it falls in the defined session window, clears an absolute volume floor, and its range-based spread proxy stays under a threshold.
//@version=6indicator("Session-Aware Fillability Gate", overlay=true)
sessInput = input.session("0930-1600", title="Regular Session")volFloor = input.int(500, title="Absolute Volume Floor")spreadMult = input.float(1.5, title="Spread Proxy Multiple")
inSession = not na(time(timeframe.period, sessInput))volOk = volume >= volFlooravgRange = ta.sma(high - low, 20)spreadProxy = high - lowspreadOk = spreadProxy <= avgRange * spreadMult
fillable = inSession and volOk and spreadOkplotchar(fillable, "Fillable", "*", location.belowbar)That absolute floor is what the percentage-only version was missing: it does not care what the recent baseline volume has been, it asks whether this specific bar has enough real size on it to make a fill plausible at all, in either session.
Documenting Fill Assumptions for Your Own Sweep
My take is that a fill assumption without a logged context is not documentation, it is a guess that happens to be written down. Every sweep result you keep should carry four fields alongside it: the spread offset tested, the depth or volume filter applied, the session window it ran in, and the walk-forward window length used to validate it. Without those four fields sitting next to the cycle count, a result from a thin-session sweep looks identical to a result from a liquid one, and six months from now you will not remember which was which. I keep this as a flat record, one row per sweep run, so that when a fill rule stops working I can trace the failure back to the exact combination of spread, depth, volume, and session that produced it rather than re-running the whole grid from scratch, as TradingView’s documentation of its broker emulator makes clear when it spells out the default assumptions behind each simulated fill, a point the broker emulator section states directly.
I recommend treating the documentation step as part of the sweep itself, not something you tack on afterward. Concretely, before you touch a parameter grid this week, write down the session windows you plan to test (pre-market, first hour, midday, last fifteen minutes), the spread offset range in ticks, and the volume or depth filter thresholds, in a single table you commit alongside your strategy code. Then run the walk-forward split exactly as you always do, but log the four context fields on every in-sample and out-of-sample result, not just the cycle count. When a result looks stable, check whether it is stable across all four session windows or only the liquid ones before you trust it; if it only holds in one window, that is the row worth revisiting next, not the aggregate.
The next step for your own sweep this week is small and mechanical: pick one strategy you already have parameters for, add the session and volume-floor fields to whatever log or spreadsheet you use for sweep results, and re-run last month’s grid once with that logging in place. You are not looking for a better number here; you are checking whether the stable region you found earlier still looks stable once you can see which session it came from. That single pass tells you whether your existing fill assumptions were ever tested against the conditions that matter, or whether they were quietly averaged across a day that never behaved the same way twice.
Fill Assumptions Are a Market-Conditions Problem, Not a Constant
Go back to the question this whole piece opened with: how do you know whether a fill rule you wrote once is still the right fill rule for the bar in front of you. The answer this sweep gives is that it is never a fixed answer, it is a lookup. Spread, depth, volume, and session are not four separate knobs you tune and forget; they are the four coordinates that tell you which fill rule applies right now, and a backtest that collapses them into one blanket assumption is really just picking a single point in that space and hoping every bar in history happens to land near it. The cycle-count table made this concrete rather than abstract: the same spread offset produced a full run of surviving walk-forward cycles in a liquid session and lost a third of them in a thin one, and the cross of a wide spread with a thin session lost far more than either factor alone. That is not a rounding error in a report; it is the backtest quietly telling you it was testing two different markets under one label. The Session-Aware Fillability Gate exists because a percentage-only volume filter cannot tell the difference between those two markets on its own, and the holiday-session failure showed exactly what happens when you trust it to.
The practical stakes for anyone running a walk-forward sweep are simple to state and easy to ignore: a parameter region that looks stable in-sample is only as trustworthy as the market conditions that region was tested against, and if you never logged spread, depth, volume, and session alongside the cycle count, you cannot tell later whether “stable” meant robust or just meant lucky enough to avoid the thin sessions during the test window. The single habit worth keeping from all of this is to treat every fill assumption as conditional and to write the condition down next to the result, every time, before you trust the number: not “this fill rule works,” but “this fill rule holds under this spread, this depth, this volume floor, in this session,” because that is the only form of the claim a future walk-forward window can actually falsify.
Sources
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.