A stop became an assumed fill
The simulator walked each candle's high, low and close to resolve targets, stops and timeouts. When a stop was touched, it priced the exit at that stop. But the next candle could open beyond the threshold. Without an opening-price input, the model could turn an adverse gap into a neatly bounded loss.
The defect was in our simulator's contract. A configured stop describes a trigger; it does not establish an available execution price. Investor.gov explains that a stop order's execution can differ from its stop price. That reference supplies the general distinction, not validation of our particular market data or fill assumptions.
The first quote in a candle is ordered evidence. Its later high and low are not.
One candle is enough
- Open the gap fixture with entry
100, stop95and next opening price85. Spread is zero to isolate the defect. - Run the comparison. The old rule exits at 95. The corrected opening-aware rule exits at 85.
- Move the opening quote to 95 or higher. The reduced fixture assumes a later stop touch, so an opening gap no longer worsens that stop fill.
| Property | Opening omitted | Opening supplied |
|---|---|---|
| Initial risk distance | 100 − 95 = 5 | 100 − 95 = 5 |
| Modeled exit | 95 | 85 |
| Return / initial risk | (95 − 100) / 5 | (85 − 100) / 5 |
| Result | −1.00 R | −3.00 R |
This is an invented arithmetic example, checked against the repository's isolated fill function. It is not a real position or a measured loss. The public interactive lab implements a smaller comparison, not the full simulator.
Use the open before the extrema
The fill function accepts an optional opening-price series. Its backtest and forward-evaluation callers now supply candle opens. For a long position, an opening quote at or below the active stop takes that opening quote as the modeled exit. The short path is symmetric. A target reached at the open fills at the target, without inventing favorable price improvement.
# Previous intrabar assumption:
if low <= stop:
exit_price = stop
# Opening-aware sequence:
opening_bid = opening_proxy - spread / 2
if opening_bid <= active_stop:
exit_price = opening_bid
elif opening_bid >= target:
exit_price = target
else:
evaluate_intrabar_barriers()The quote basis also matters. Under this model's midpoint-proxy convention, a long entry uses proxy plus half-spread and its exit uses proxy minus half-spread. Short positions use the reverse sides. The same convention applies to barrier touches and breakeven activation, so a displayed midpoint touching a target does not automatically imply an executable fill.
After the open, OHLC cannot reveal the order of the extremes. The simulator checks an already-active stop before moving it to breakeven. If the opening quote itself activates breakeven, that event is known to precede the later extremes. These are explicit conservative ordering rules, not a reconstruction of ticks.
Check the accounting path, too
A helper fix is insufficient if its callers omit the new input or downstream metrics still clamp losses. The regression suite covers both the fill function and its integration with simulated returns. The tests load reviewed functions with synthetic inputs, without starting broker clients.
- Long and short stop gaps can lose more than one initial risk unit. Gap fills use the executable side of the spread.
- An opening stop precedes a later rebound; an opening target precedes later adverse extremes and receives no assumed improvement.
- Gaps through a previously moved breakeven stop still lose money. Opening-time activation and ambiguous intrabar activation are separate cases.
- Normal opens preserve previous nongap results. Missing opens remain compatible but explicitly cannot model gaps; short or nonfinite opening series are rejected.
- Both simulation arms pass their opening data through, and risk-weighted returns retain losses larger than −1 R.
The public fixture isolates the default gap example. It does not represent the full coverage of the private execution suite, and no historical test total is presented as a live test counter.
A better model with stated limits
The change removes one favorable execution assumption. It does not establish a profitable strategy or a complete execution simulator. Existing experiments need a clearly labeled replay before results produced under different fill conventions can be compared.
MATERIAL LIMITS
The input source may contain bid candles rather than true midpoint candles; that basis still needs normalization. Fixed spreads, opening quotes and OHLC do not describe order-book depth, queue priority, partial fills, additional slippage, broker rejection, commissions or swaps. Opening-price execution remains a modeling assumption. A conservative bar-order rule can bound one ambiguity while leaving other uncertainties unresolved.
For simulation, data-platform and reliability roles, the engineering value is the chain of evidence: identify a missing input, state an ordering contract, update every caller, verify adverse outcomes and keep an observable result separate from an assumption. The repair makes the model more inspectable, even when it makes the result worse.
PRIMARY REFERENCE & PUBLIC ARTIFACT
- Investor.gov: Stop Order — stop triggers and execution-price uncertainty.
- SEC investor bulletin on stop orders — execution can deviate from the trigger price.
- Interactive synthetic gap fixture and offline reproduction — reduced, inspectable public examples.