Skip to content
Sign In

Learning / Syntax / rem / cancel

rem / cancel - Cancel Open Orders

Cancel pending orders to clean up before opening new positions or manage existing orders.

What is rem / cancel?

rem (or cancel) removes open orders from the exchange. It only affects orders on the symbol in your webhook (e.g., if your webhook is for BTCUSDT, it will only cancel BTCUSDT orders). Both commands are aliases.

Common Use Cases:

  • Clean Slate Strategy

    Cancel all orders at the start of your webhook to ensure fresh state

  • Timed Order Cleanup

    Place order, wait for time to pass, then cancel if not filled

  • Strategic Order Management

    Cancel only buy orders, only sell orders, or specific tagged orders

Syntax

Smart Syntax
rem all|buy|sell|long|short|session
rem tp|sl|tpsl
rem limit|market|stop|entry
rem #tag
// 'cancel' is an alias for 'rem'
cancel all|buy|sell|long|short|session
cancel tp|sl|tpsl
cancel #tag

Parameters

scopeRequired

Type: keyword or tag | Default: session

Determines which orders to cancel:

SyntaxWhat Gets Cancelled
rem allALL open orders for this symbol on the exchange
rem buy or rem longAll open buy/long orders only
rem sell or rem shortAll open sell/short orders only
rem sessionOnly orders created in this webhook execution
rem tp or rem takeprofitOnly take profit orders
rem sl or rem stoplossOnly stop loss orders
rem tpsl or rem sl-tpBoth TP and SL orders with atomic cancellation (OCO-aware)
rem limitOnly limit orders
rem marketOnly market orders (rarely useful since market orders execute instantly)
rem stopOnly stop orders (stop-market or stop-limit)
rem entryOnly entry orders (non-reduce-only orders)
rem #tagOnly orders with the specified tag

Real-World Examples

1. Clean Slate - Cancel Everything Before Trading

Most common pattern: cancel all existing orders and close position before starting fresh.

Smart Syntax
BTCUSDT on My_API_Key
// Clear everything
rem all
pos 0
// Now start fresh
market long 0.01
sl-or-tp short 100%p sl off 2% tp off 5%

This ensures no old orders interfere with your new strategy. Best practice for most strategies.

2. Timed Order - Cancel if Not Filled

Place a limit order, wait 30 minutes, then cancel it if it hasn't filled yet.

Smart Syntax
BTCUSDT on My_API_Key
// Place limit order with tag
limit long 50% off 1% #entryOrder
// Wait 30 minutes
wait 30m
// Cancel if not filled
rem #entryOrder

If the limit order fills before 30 minutes, there's nothing to cancel. If it's still pending, it gets cancelled.

3. Cancel Only Buy Orders

Cancel buy orders while keeping sell orders active (useful when switching strategy direction).

Smart Syntax
ETHUSDT on My_API_Key
// Cancel all pending buy orders
rem buy
// Keep sell orders, add new short entry
market short 0.5

This is useful when you had buy orders waiting but now want to go short instead.

4. Session Orders Only

Cancel only orders created in this webhook execution, leaving older orders untouched.

Smart Syntax
BTCUSDT on My_API_Key
// Place multiple orders
limit long 25% off 1%
limit long 25% off 2%
limit long 25% off 3%
// Later: cancel only these 3 orders
wait 1h
rem session

rem session only affects orders created in THIS webhook run, not old orders from previous signals.

5. Tagged Order Groups

Create multiple order groups with tags, then cancel specific groups independently.

Smart Syntax
BTCUSDT on My_API_Key
// Entry orders group
limit long 25% off 1% #entries
limit long 25% off 2% #entries
// Exit orders group
limit short 50% off -3% #exits
limit short 50% off -5% #exits
// Later: cancel only entry orders
wait 15m
rem #entries

Tags let you organize orders into logical groups and manage them independently. Very powerful for complex strategies.

Best Practices

  • Start webhooks with rem all - Ensures clean state, prevents orphaned orders

  • Use tags for complex strategies - Label order groups to manage them independently

  • Combine with wait - Place orders, wait for fill time, cancel if not executed

  • Cancel before reversing direction - rem buy before going short

Common Patterns

Strategy Reset

Smart Syntax
rem all
pos 0

Clears all orders and closes position - fresh start


Timed Entry

Smart Syntax
limit long 50% off 1% #entry
wait 30m
rem #entry

Wait for fill, cancel if not executed within time


Direction Switch

Smart Syntax
rem buy
market short 0.01

Cancel buys, go short - useful for trend reversals

Related Commands

oco

- Automatic OCO monitoring for competing orders

wait

- Pause before cancelling orders

limit

- Create orders that can be tagged for later cancellation