Cancel

Use [[cancel]] to cancel all pending orders associated with a given order_id. It targets orders emitted by [[entry]], [[order]], and [[exit]] as long as they have not yet been executed.

If the cancellation removes an entry before execution and there is no open position for that entry, the exit orders tied to that entry are also cancelled.

It is particularly useful for invalidating price orders if market conditions change before they are hit.

Block declaration

A strategy can contain multiple [[cancel]] blocks.

Examples

Cancelling a pending entry

This example cancels the pending order identified by long_limit.

[[cancel]]
id            = "cancel_limit_order"
order_id      = "long_limit"
next_block_id = "restart_logic"

Immediate cancellation with reroute

This example cancels pending orders linked to tp_order and immediately continues to restart_logic.

[[cancel]]
id            = "clean_up"
order_id      = "tp_order"
wait_candles  = 0
next_block_id = "restart_logic"

Block Parameters

ParameterDescription
id
 Text
 Required
Unique identifier for the block.
order_id
 Text
 Required
Target identifier for the cancellation. The block cancels all pending orders that share this order_id, including those emitted by [[entry]], [[order]], and [[exit]]. If that order_id targets a deferred [[exit]] already armed with from_entry but not yet materialized, that deferred intent is also cancelled.
next_block_id
 Text
 Required
Identifier of the block to execute next.
wait_candles
 Integer
 Optional
Number of candles to wait before executing the next block. Use 0 to disable the delay.
Default value: 0