NextBarOpen
NextBarOpen is a deprecated ProBacktest and ProOrder modifier that delayed orders to the next bar open, now the default behavior for every market order.
Syntax
AT MARKET NextBarOpenHow it works
In early versions of the platform, NextBarOpen was appended to a market order to state explicitly that the order should execute at the opening price of the following bar rather than at the current price. The intent was to model realistic execution: a signal computed on a finished bar can only be traded once the next bar starts.
That execution model later became the only one. Strategy code is evaluated once per bar, at the close, and any market order generated during that evaluation is transmitted immediately afterward, filling at the open of the next bar. The behavior NextBarOpen used to request is now the unconditional default, which makes the modifier redundant.
The official position is that the instruction is no longer valid and serves no purpose. Existing code that carries the modifier documents an intent the engine already guarantees, and new code should never include it. When the keyword appears in older strategies found in archives or forums, it can be deleted without changing the strategy's behavior under the current execution model.
NextBarOpen should not be confused with TomorrowOpen, which is a distinct instruction related to daily-bar order timing and remains a separate keyword.
Examples
Example 1, Legacy entry with the modifier (ProBacktest)
// legacy code: NextBarOpen is redundant under the current engine
IF NOT ONMARKET THEN
BUY 2 CONTRACTS AT MARKET NextBarOpen
ENDIFThe order fills at the open of the next bar with or without the modifier. This is the form found in older published strategies.
Example 2, Legacy short entry (ProOrder)
short = close < Average[100](close)
// older strategies attached NextBarOpen to short entries as well
IF NOT ShortOnMarket AND short THEN
SELLSHORT 1 CONTRACT AT MARKET NextBarOpen
ENDIFThe same pattern on the short side. Removing the trailing keyword leaves execution identical, the short opens at the next bar's opening price either way.
Example 3, Migrating old code (ProBacktest)
// before: BUY 2 CONTRACTS AT MARKET NextBarOpen
// after, same behavior:
IF NOT ONMARKET THEN
BUY 2 CONTRACTS AT MARKET
ENDIFThe modernized form. Deleting NextBarOpen from an old strategy is a pure cleanup, no compensation elsewhere in the code is needed.
Common errors and gotchas
- Expecting a timing difference. Adding or removing
NextBarOpenchanges nothing. All market orders generated at a bar close execute at the next bar open. Code comparisons that attribute different results to the modifier are looking at the wrong variable. - Possible rejection by current compilers. The instruction is documented as no longer valid. Depending on the platform version, code containing it may fail to compile, so the safe migration is to delete the keyword rather than keep it for nostalgia.
- Confusion with
TomorrowOpen. The names look related but the instructions are not interchangeable.TomorrowOpenconcerns daily-bar order placement and is still a live keyword,NextBarOpenis a dead modifier. - Assuming same-bar execution exists. Removing the modifier does not enable same-bar fills. There is no order type that executes at the close of the signal bar, the next-bar-open model is inherent to the engine.
Related instructions
TomorrowOpen, order timing instruction for daily bars.MARKET, immediate execution at the current market price.BUY, opens or adds to a long position.SELL, closes some or all of a long position.SELLSHORT, opens or adds to a short position.EXITSHORT, closes some or all of a short position.LIMIT, pending order that fills at a set price or better.STOP, pending order that triggers once price reaches a level.
