Execution rules: strategy controls

E18 Opposite signals, E19 Limits checked at the fill, E20 Loss guards, E21 Order of work at a bar close, E22 Trading hours

E18Opposite signals#

With opposite: ignore (the default), entries opposite an open trade are rejected. With close, the opposite entry closes open trades at its fill price and opens nothing. With reverse, it closes open trades and opens the new trade at the same price. With hedge, it opens alongside open trades where the venue supports hedging, and behaves as ignore elsewhere.

E19Limits checked at the fill#

When an entry fills, it is rejected with a reason if it would exceed max_open, max_open_per_side, one plus pyramiding trades in the same direction, or max_total_risk, or if it would be closer than min_distance to the entry price of an open trade in the same direction. Pending orders are checked when they fill, not when they are placed.

E20Loss guards#

At each bar close, the day's closed profit plus the open profit at that close is compared with max_daily_loss. When the limit is reached, all trades close and pending orders are cancelled at the next bar's open, and new entries are rejected until the next UTC day. max_drawdown works the same way against the highest equity reached, and pauses the deployment until it is resumed.

E21Order of work at a bar close#

At each bar close the runtime (1) completes the fills and management inside the bar in path order, (2) runs on fill and on exit for them in the order they happened, (3) runs calculations, (4) updates confirmations and sequences, (5) runs rules and on bar close in script order, (6) records exports and drawing, so outputs always see this bar's final values, and (7) queues the orders the rules created for the next bar. Queued closes run before queued entries. Indicator calls update on every bar, even when their line sits in a branch that did not run.

E22Trading hours#

With trade_only, entries are only created at the close of bars that open inside the listed sessions; other entries are skipped with a reason. Exits, management and pending orders already placed continue outside the sessions.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account