Skip to content
Algo Trade Analytics Docs

strategy.cancel() - Pine Script Function

Cancels a pending or unfilled order with a specific identifier. If multiple unfilled orders share the same ID, calling this command with that ID as the id argument cancels all of them. If a script calls this command with an id representing the ID of a filled order, it has no effect.

strategy.cancel(id) → void
NameTypeDescription
idseries stringThe identifier of the unfilled order to cancel.
//@version=6
strategy(title = "Order cancellation demo")
conditionForBuy = open > high[1]
if conditionForBuy
strategy.entry("Long", strategy.long, 1, limit = low) // Enter long using limit order at low price of current bar
if `conditionForBuy` is `true`.
if not conditionForBuy
strategy.cancel("Long") // Cancel the entry order with name "Long"
if `conditionForBuy` is `false`.