Skip to content
Algo Trade Analytics Docs

strategy.cancel_all() - Pine Script Function

Cancels all pending or unfilled orders, regardless of their identifiers.

strategy.cancel_all() → void
//@version=6
strategy(title = "Cancel all orders demo")
conditionForBuy1 = open > high[1]
if conditionForBuy1
strategy.entry("Long entry 1", strategy.long, 1, limit = low) // Enter long using a limit order
if `conditionForBuy1` is `true`.conditionForBuy2 = conditionForBuy1 and open[1] > high[2]float lowest2 =
ta.lowest(low, 2)
if conditionForBuy2
strategy.entry("Long entry 2", strategy.long, 1, limit = lowest2) // Enter long using a limit order
if `conditionForBuy2` is `true`.conditionForStopTrading = open < lowest2
if conditionForStopTrading
strategy.cancel_all() // Cancel both limit orders
if `conditionForStopTrading` is `true`.