The price never traded through your stop: test opening gaps
Distinguish price gaps from missing data, model executable quotes at reopening and test exits without inventing liquidity between two observations.

The chart drew a route the market did not offer
Two points appear on a chart: the last quote before a session closes and the first quote after it reopens. The charting software joins them with a line. Halfway along that line sits the strategy’s planned exit level. A naive backtest treats the crossing as an execution and reports a neatly contained loss. But the line is a drawing between observations, not evidence that the market offered every intermediate price.
This fictional example identifies the central problem of a price gap. A planned exit level is not proof of an executable price. If the first available quote lies beyond the level, the model needs a rule for what happens at that quote, under the relevant execution convention. It cannot fill the missing interval with imaginary liquidity merely because the strategy had an instruction there.
We will build a gap stress test around a hypothetical long position in a dollar-quoted currency pair. The numbers are invented for teaching and do not describe the demo robots’ performance. The focus is the distinction between a discontinuous trading opportunity, a missing data interval and a simplified price chart. Those distinctions determine what a backtest can legitimately infer.
A useful gap study is not a prediction that a particular event will occur. It is an investigation of the policy’s behavior when the next executable observation differs materially from the previous one. It asks which positions remain exposed, which rules activate, what prices are assumed available and how the account result is reconciled. The answer can reveal limitations that an ordinary smooth-path backtest never exercises.
A market closure and a hole in the file are different facts
An empty interval in a dataset has several possible explanations. The instrument may be unavailable for trading under the provider’s session schedule. The data source may have failed while trading continued elsewhere. The archive may deliberately omit intervals with no updates, or its timestamps may have been converted incorrectly. These possibilities cannot be distinguished simply by seeing a blank space in a chart.
Start with the session calendar and data provenance. Identify the instrument, provider, timezone and the schedule applicable to the observations being studied. Daylight-saving changes, holidays and provider-specific interruptions can affect the boundary. Do not assume that a fixed local hour copied from an unrelated example correctly describes every historical session or every account arrangement.
OANDA’s hours documentation notes that prices can change materially when trading resumes and that closing conditions can differ from ordinary periods. This is a provider-specific description of reopening risk, not a universal schedule. OANDA: hours of operation. A concrete study should preserve the schedule and conventions relevant to its own data rather than importing a generic calendar without checking it.
Missing observations do not prove that no trading opportunity existed. Conversely, a known closure does not authorize an execution inside the closed interval. Label the reason for each gap where it is known, and retain an unknown category where it is not. A data-quality problem may prevent a conclusion about execution even when the strategy logic is perfectly clear.
This distinction protects both sides of the analysis. It prevents optimistic interpolation across a genuine closure, and it prevents every feed failure from being interpreted as an extraordinary market jump. The research can then decide whether to repair data, exclude a clearly documented interval or impose a separate hypothetical stress. Each action has a different evidential meaning and should be recorded as such.
Define the last quote, the first quote and the side you need
A gap needs a precise reference. Is it measured from the last bid, last ask, midpoint, trade or bar close? Is the first observation a usable quote for the intended quantity or merely the first record in the archive? These choices affect both the measured jump and the simulated execution. A number called “the opening gap” is incomplete until its two endpoints are defined.
For a long position that is closed by selling, the bid side is relevant under a simple quoted-price convention. For a short position closed by buying, the ask side matters. A midpoint can be useful for describing market movement, but it does not automatically represent either executable side. Spread changes at reopening can therefore alter the exit result even when the midpoint move is unchanged.
Suppose the last hypothetical quote is bid 1.0960 and ask 1.0962. The first reopening quote is bid 1.0890 and ask 1.0896. The bid falls by 0.0070, or 70 pips under a 0.0001 pip convention. The midpoint moves from 1.0961 to 1.0893, or 68 pips. Both descriptions are arithmetically correct, but they refer to different price objects.
Keep the quote pair together. Recording only a midpoint and a separate average spread can lose the opening quote’s actual relationship between sides. If the archive lacks bid and ask, a reconstructed spread is an assumption and should be labelled. It may support a sensitivity exercise, but it is not an observed executable quote merely because it has four decimal places.
Also preserve quote age and availability. The first timestamp in a file might contain a stale value carried forward from the prior session. A gap calculation should not quietly treat that stale record as fresh liquidity. Establish a rule for identifying the first usable observation and explain what remains unknown about quantity, latency or execution beyond the displayed price.
The paired quotes also let us separate midpoint movement from spread widening. At the hypothetical reopening midpoint of 1.0893, retaining the old two-pip spread would imply a bid of 1.0892. The actual imposed six-pip spread instead gives a bid of 1.0890. For a sale of 10,000 units, that two-pip difference is USD 2. This is a diagnostic decomposition at a fixed midpoint, not a claim that the narrower quote was available. It shows how two mechanisms can contribute to the exit result without being counted twice. A report that calls the entire bid change a pure midpoint jump would conceal the spread contribution, while a report that adds the full widening again after using the bid would overstate it.
Work through a position that remains open across the boundary
Consider a hypothetical long position of 10,000 base units entered at 1.1000 in a dollar-quoted pair. Its planned stop level is 1.0950. Under a simplified stop-price calculation, the intended loss before other costs is 10,000 times 0.0050, or USD 50. That is a planned level calculation, not a guarantee of the eventual exit price.
At the last bid of 1.0960, the position’s marked-to-market result against its entry price is negative USD 40. At the first reopening bid of 1.0890, the same position is worth negative USD 110 relative to entry. The change across the boundary is negative USD 70. These three quantities must remain separate: planned stop-level loss USD 50, total reopening loss USD 110 and incremental boundary loss USD 70.
If the scenario assumes the position can be closed at the first bid, its price-related loss is USD 110 before any additional separately modelled charges. The difference from the planned stop-level loss is USD 60. We do not add another full spread automatically, because the bid-side exit convention already includes that side of the quote. Other costs need their own explicit treatment.
A gap loss measured from the last close is not the whole trade loss. Mixing the two can understate or double count the result. The opening position already carried an unrealized loss of USD 40 before the boundary. The additional USD 70 brings the total to USD 110. A reconciliation from entry through the last valuation to the reopening makes the accounting transparent.
The example assumes a particular first-quote execution for a particular quantity. If the model introduces delay or unavailable liquidity, it must calculate another path. The stated USD 110 is not a worst-case bound. It is the consequence of the exact quote and execution assumption supplied to this teaching scenario.
A trigger and an execution rule are not the same thing
A stop condition can identify when a policy should attempt to exit, but the eventual execution depends on the applicable mechanism and available prices. Investor.gov explains, in the context of stock orders, that a stop price is not a guaranteed execution price. Investor.gov: understanding order types. That source describes equities; a Forex implementation must use its own provider’s contract and execution rules rather than assuming every detail transfers unchanged.
OANDA’s volatility guidance likewise states for its relevant service that stop-loss instructions may not fill at the requested price and that gaps can increase the difference from a targeted price. OANDA: considerations for managing volatility. The article uses these sources only to establish the distinction between a target and an assured fill, not to prescribe a particular order choice.
A limit condition changes the constraint on acceptable execution price; it does not create liquidity at that price. A model that refuses a worse price may leave exposure open. That can be a coherent policy scenario, but it cannot simultaneously claim an immediate exit at the protected level when the assumed quote never offered it. Price protection and certainty of execution are different properties.
The research should describe its rule in plain language. For example, does a breached threshold lead to a simulated exit at the first eligible quote, to a delayed decision or to a constrained instruction that may remain unfilled? What happens while exposure remains open? Which observations determine eligibility? These details can materially change the path and should not be hidden behind a generic label such as stop loss.
Do not infer a contractual guarantee from the strategy’s source code. Code can express an intended condition, but it cannot by itself establish the provider’s execution obligations or the available market. If a particular service offers a special guaranteed mechanism, its terms and costs would need separate evidence and modelling. The general gap test should not assume such a mechanism unless it is explicitly part of the defined environment.
Never interpolate an executable path just to make the stop work
Interpolation is useful for some descriptive tasks, but it can be dangerous when used to invent execution opportunities. Connecting the last and first quote with a straight line creates intermediate values that may never have been available. If a backtest executes a stop at one of those invented values, the smooth path has changed the economic scenario rather than merely improving the chart’s appearance.
A bar’s high and low also do not reveal the complete order of events. If both an entry threshold and an exit threshold lie within one bar, their sequence may be unknown at that resolution. At a session boundary, the problem can be stronger: the path between the two recorded quotes may not be a continuous sequence of tradable prices at all. The model must distinguish insufficient temporal detail from a known unavailable interval.
Preserve discontinuity where the scenario imposes discontinuity. A synthetic gap should leave the position exposed from the last usable quote to the next eligible one. If the policy cannot act during the interval, the simulation should not grant it an intermediate action simply because an interpolated series contains a convenient crossing. This is an execution assumption, not a plotting preference.
If finer data exist, use them to investigate the relevant sequence under a declared matching rule. If they do not, report the ambiguity or compare clearly labelled alternatives. Avoid silently choosing whichever intrabar ordering gives the best result. A conservative scenario can be useful, but it should be identified as imposed rather than described as the uniquely observed history.
The same principle applies to repaired datasets. Filling a missing record for an indicator calculation is not necessarily permission to execute at the filled value. Keep analytic imputations separate from the set of prices considered eligible for execution. That separation allows a model to maintain a continuous feature calculation without fabricating a continuous market.
Use a small grid of gap sizes and execution assumptions
Return to the hypothetical long position entered at 1.1000 with a last bid of 1.0960. Impose three downward bid gaps of 10, 40 and 100 pips. The first bids become 1.0950, 1.0920 and 1.0860. If the scenario closes 10,000 units at those first bids, the price-related losses from entry are USD 50, USD 80 and USD 140 respectively, before separately modelled charges.
The grid holds quantity and the first-quote execution rule fixed while changing gap size. It therefore isolates one mechanism. It is not a forecast of the frequency of those gaps, and the largest selected scenario is not a maximum possible market move. A scenario range chosen for investigation should be described as a range, with a reason for its selection, rather than presented as a complete description of future risk.
Next change execution timing in a separate layer. In the 100-pip scenario, suppose the model waits until a later eligible bid of 1.0858. The loss from entry becomes USD 142. The additional USD 2 follows from the imposed two-pip move after reopening. This is not a measured latency effect; it is a transparent hypothetical consequence of the later quote.
Gap size and post-opening execution are separate inputs. A model that changes both at once may be useful for combined stress, but it should not attribute the entire result to the gap alone. Similarly, changing position size or financing at the same time adds further mechanisms. Keep a simple reference scenario so that each additional assumption has an identifiable effect.
Include upward gaps or positions with the opposite sign where they are relevant to the research question. A stress study can focus on adverse outcomes, but it should not accidentally reverse the sign convention or apply a long-position exit rule to a short position. Small hand-calculated cases are a good way to check these details before running a large scenario collection.
Study the rule that determines whether exposure crosses the boundary
A gap affects the positions that remain exposed across it. The policy deciding whether to carry a position is therefore part of the experiment. A rule that closes before a scheduled boundary, a rule that continues to hold and a rule that conditionally reduces exposure are different strategies. Their results cannot be compared by simply deleting the gap loss from one historical report.
If the research evaluates a pre-close exit rule, it must model the exit opportunity before the boundary and any costs associated with it. The quote may differ from the last recorded close, and the instruction may need to occur before a provider-specific cutoff. The revised policy may also miss subsequent favorable moves or require a new entry later. Those consequences belong in the comparison.
Avoiding one exposure interval changes the opportunity set. A filtered strategy can have lower gap sensitivity while also changing gross return, holding time and turnover. A useful report attributes those changes instead of labelling every reduced loss as free protection. The choice of whether to carry exposure is a research policy question here, not a universal recommendation for every trader or system.
The information available when the carry decision is made must be explicit. A rule that closes only before gaps later observed to be large uses hindsight. A legitimate conditional rule needs inputs available before the boundary, along with a declared decision time. If the rule was selected after reviewing historical gaps, preserve that development history and evaluate the revised policy under a separate protocol.
This is a good place for a simple counterfactual ledger. Record the original intended position, the revised decision, the assumed pre-close execution and the subsequent path each policy follows. Do not mix the original policy’s favorable post-opening trades with the revised policy’s avoided losses unless the revised logic actually produces that combination. The ledger should make each policy internally coherent.
Several systems can meet the same reopening event
A portfolio may contain several positions when a session resumes. Their gap consequences can share a market event, a currency exposure or a provider condition. Analysing each position’s worst isolated gap and then assuming those losses cannot coincide is one kind of error. Adding every individually worst historical gap as though they occurred simultaneously is another. A joint scenario needs a coherent shared event.
Start with the actual or hypothetical positions at the boundary. Define the set of reopening quotes together, including relevant currency-conversion rates. Then calculate the account result under its rules. A position with a different instrument name may still share a currency side with another, while an offsetting position may reduce one exposure without eliminating all costs or constraints.
The portfolio’s response can be state-dependent. Simultaneous losses may change available resources or trigger an account-level rule before every component completes its planned action. If the model studies that behavior, it must simulate the ordering and constraints explicitly. Summing unconstrained individual exits may describe a useful reference calculation, but it is not automatically the result of the constrained account policy.
An account-level result needs an account-level reconciliation. Combine position values, costs and any explicitly modelled adjustments under one currency convention. Preserve the difference between gross exposure and net exposure. A seemingly small net currency position can coexist with substantial gross positions and transaction costs, depending on how the account handles them.
The companion article on cross-market dependence develops the broader joint-scenario problem. In a gap study, the specific contribution is the unavailable interval and the first opportunities afterward. Keeping that boundary explicit prevents an otherwise sensible portfolio analysis from granting every component a continuous route to its preferred exit.
Construct synthetic gaps without creating impossible records
A synthetic gap is an imposed experiment, so its construction should be simple enough to inspect. Choose a boundary, preserve the pre-boundary state and define the first eligible post-boundary quotes. If the later path is shifted or otherwise transformed, document how the transformation affects both sides of the quote and any derived features. The goal is to create a coherent scenario, not merely a visually dramatic chart.
Check basic consistency. The ask should not fall below the bid under the chosen convention. Bar highs and lows should agree with the underlying observations if bars are reconstructed. Timestamps should remain ordered, and the unavailable interval should not contain invented executable records. A synthetic change that breaks these identities can produce strange strategy behavior unrelated to the intended gap mechanism.
Do not recompute the past using the future shock. If the scenario inserts a gap at a boundary, signals and positions before that boundary should remain based on information available beforehand unless the experiment explicitly changes earlier data. Recalculating a historical indicator with a future-adjusted series can accidentally alter the position that was supposed to face the gap, mixing setup changes with the stress itself.
There are different legitimate experiments. One can hold the pre-gap position fixed and calculate its response. Another can rerun a complete policy on a modified path from a declared starting point. The first isolates a conditional exposure; the second studies a strategy under a broader synthetic environment. Neither should be presented as the other. State what is frozen and what is recalculated.
Keep the original data separate from the scenario representation. Record the transformation, boundary and affected fields so the imposed path can be reproduced. A scenario should not overwrite the historical archive and then be mistaken for observed market data later. Provenance is especially important when the same files are used by an AI assistant for further analysis or code generation.
A severe scenario is not a probability estimate
A historical archive can describe the gaps it contains, under its coverage and measurement conventions. It cannot establish that the largest observed gap is a hard future bound. Rare events, changes in market structure and incomplete coverage can all limit extrapolation. The article’s selected 10-, 40- and 100-pip scenarios are teaching inputs, not estimated quantiles or a recommended stress standard.
Separate the question “what happens under this gap?” from “how often might this gap occur?” The first can be answered conditionally with a coherent price and execution model. The second requires a defensible statistical population, observation process and treatment of rare outcomes. It is acceptable for a research exercise to answer the first while leaving the second unresolved.
Do not label a scenario percentile unless it was estimated as one. A dramatic name, a familiar crisis date or a large round number does not create a probability. If a historical event is replayed, identify the data and what the current policy is assumed to do in that event. If the event is hypothetical, state the imposed conditions and avoid implying that the model measured their likelihood.
Sensitivity can still guide useful work. If modest changes in the first eligible quote or execution delay change the conclusion materially, the next investigation should focus on those assumptions and the available evidence. If a result is stable across a declared range, that supports only the stated conditional sensitivity finding. It does not establish safety outside the range or under mechanisms the experiment omitted.
This distinction keeps the report practical. Instead of producing an unsupported annual loss forecast, it can identify where the strategy’s accounting, execution logic or exposure policy needs closer examination. A well-defined unresolved question is more useful than a precise-looking probability derived from an arbitrary scenario menu.
Build checks around the discontinuity itself
The most useful implementation checks target the boundary. With a zero gap and unchanged quotes, the stress engine should reproduce the declared reference behavior. With no open exposure and no eligible action, the boundary should not create a position loss. A long and short test should use the appropriate quote side under the chosen convention. These are small cases with known answers, not performance tests of a trading strategy.
Check that an exit level inside the unavailable interval does not receive an invented fill. In the worked example, a rule that assumes first-bid execution after reopening must use 1.0890, not 1.0950. The entry-to-exit loss should reconcile to USD 110, with USD 40 already present before the boundary and USD 70 added across it. A mismatch points to accounting or execution logic before it says anything about market behavior.
Also test the first observation’s eligibility. A stale carried-forward quote should follow the declared stale-data policy, not quietly count as a fresh reopening. A missing ask should not be replaced with a favorable value without an explicit reconstruction assumption. Data availability is part of the execution experiment. The simulator should expose uncertainty rather than resolve it silently in whichever direction helps the result.
Preserve event traces for a few scenarios. Each trace should show position before closure, last valuation, unavailable interval, first eligible observation, triggered conditions, assumed execution and final reconciliation. A reviewer can often detect an impossible intermediate action from this trace more easily than from aggregate statistics over thousands of scenarios.
Make the final report explicit about what was available
A concise gap report should identify instrument and account conventions, the boundary calendar, quote endpoints, position quantities, execution rules and any additional costs. Separate observed historical data from imposed scenarios. State the time resolution and the meaning of the first eligible quote. These details explain the result far better than a headline showing only an enlarged drawdown percentage.
Present both incremental boundary effects and total trade or account outcomes where relevant. The reader should not have to guess whether a USD 70 loss means the entire trade or only the change from the last valuation. Show how open losses before the boundary carry into the final result. Avoid double counting spreads or price movement already included in the executable-side quote convention.
The report should reveal the prices the policy could use and the prices it could not. A gap is precisely a situation in which that distinction matters. If the archive cannot determine availability, the report should say which assumption was imposed. Clear uncertainty is preferable to a smooth backtest path whose intermediate fills were never supported by the data.
Keep any proposed policy change separate from the diagnostic result. A new pre-close rule, a different execution constraint or a revised freshness condition creates a version to evaluate. The gap study can motivate that work, but it does not establish that the change improves every aspect of the system. Preserve the original comparison so that the reason for the revision remains auditable.
A first exercise with one position and two quotes
Start with a single hypothetical position, a last usable quote and a first usable reopening quote. Calculate the pre-boundary mark, incremental gap effect and total result by hand. Write the execution rule in one sentence, including which quote side is used. Then ask an AI assistant to reproduce the calculation and explain why an interpolated crossing is not an observed fill.
After the small case reconciles, add one complication at a time: a wider reopening spread, a later eligible quote, a different position sign or a state-dependent response. Preserve the reference example so each difference can be attributed. This progression creates a useful test suite without pretending that a handful of artificial cases constitutes evidence of future profitability.
The TradeAndRoll free demo contains ten Forex systems, rules, source code, market CSVs and research prompts. Those materials can be inspected to identify holding periods, quote conventions and the additional information needed for a gap study. The existence of a stop in the code does not establish a guaranteed fill, and the available CSV fields should be checked before claiming a complete execution reconstruction.
A chart can draw through a price that the market never offered. A sound gap experiment refuses that shortcut. It preserves the boundary, uses explicit eligible quotes and follows the policy’s actual assumptions through to the account result. That gives the next research decision a concrete foundation: not where the line crossed, but what the system could do when trading became available again.



