Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

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`.