Sidechair

strategy.cancel_all()

Browse the reference

Cancels every pending order of the strategy: entries, orders and exits that have not filled.

Try it in the editor

strategy.cancel_all() clears the order book. Open trades stay open; only waiting orders are removed.

Pair it with strategy.close_all() to leave the market completely.

Syntax

Pine Script
strategy.cancel_all() -> void

Returns

Nothing.

Remarks

  • Only available in strategy scripts.
  • Pending strategy.exit orders are removed too, so an open position loses its stop and target. Call strategy.exit again on a later bar if the position stays open.

Example

Pine ScriptClear orders after the closeOpen in editor
//@version=6
strategy("Cancel all at the close", overlay = true)
if session.isfirstbar
    strategy.entry("Buy stop", strategy.long, stop = high + syminfo.mintick)
if session.islastbar
    strategy.cancel_all()
    strategy.close_all()
bgcolor(session.islastbar ? color.new(color.gray, 85) : na)

See also

Runs on Sidechair