Cancel the oldest or newest orders (cm= and cmo=)
You have five limit orders resting on one symbol and you want to pull two of them, not all five. c=order on its own cancels every open order that matches the line. Add cm= to cap how many go, and cmo= to choose which ones.
c=order cm=2 cmo=newestThat line cancels the two most recent open orders and leaves the rest. This page comes from the Autoview integrations code that runs on our servers today. We read the code; we did not re-run each exchange live for this guide. Test your own line with d=1 before you rely on it.
How cm= counts
- The default is cm=100%. Leave it off and every matching order is cancelled.
- A plain number is a count.
cm=2cancels at most two orders. - A percent is taken of the matching orders, then rounded to a whole number. With 5 matching orders,
cm=50%cancels 3. With 3 matching orders,cm=10%rounds to 0 and cancels nothing. - The count comes after your other filters. Autoview first drops orders that fail the rest of the line, such as
b=,fp=,id=or at=type filter, and only then appliescm=to what is left.c=order t=close cm=1cancels one order the exchange counts as close, not one of any order, on exchanges that readt=. See cancel only stops or only entries, by exchange.
When cm= is not smaller than the number of matching orders, Autoview cancels them all and does not sort.
How cmo= picks which orders go
| cmo= | Cancels first |
|---|---|
oldest (default) | The orders placed earliest. |
newest | The orders placed most recently. |
lowest | The orders with the lowest price. |
highest | The orders with the highest price. |
smallest | The orders with the smallest size. |
biggest | The orders with the largest size. |
random | A random pick. |
What each exchange can sort by
Most exchanges support every cmo= value above. The differences:
- Tradovate supports only
oldest,newestandrandom. Ask forlowest,highest,smallestorbiggestand the command stops with "does not support sort method" in your log. Nothing is cancelled. - Binance USD-M and COIN-M futures sort
oldestandnewestby the order's last update time, not the time it was placed. An order that has partly filled or been modified since counts as newer. Binance spot and Binance.US use the time the order was placed. - Gemini and Kraken Futures sort
smallestandbiggestby the part of the order still unfilled. Other exchanges use the order's size as placed. - TradeStation sorts
lowestandhighestby the price TradeStation uses for buying power on the order. We have not checked that it always equals your limit price. - OKX applies
cm=twice: once to plain limit orders and once to stop, trigger and trailing orders.c=order cm=1on OKX can cancel one of each. - KuCoin Futures copy trading does not support
c=orderat all, socm=never applies there.
Two things to watch
- A misspelled cmo= is not rejected.
cmo=latestorcmo=lastmatches no known value, so Autoview skips the sort and cancels the first orders in whatever order the exchange listed them. Check the spelling against the table above. - Price and size sorts compare the value exactly as the exchange sends it. Autoview does not convert it to a number first. If an exchange sends prices as text, 10.2 can sort below 9.5 because text compares character by character. We have not checked which exchanges send text. Prices with the same number of digits sort correctly either way. When it matters, use
oldest,newestor a price filter withfp=instead.
It works on c=position too, with one catch
The same cap and sort run when Autoview closes positions with c=position. The catch is the default sort. Several exchanges do not give Autoview a time for an open position, so oldest and newest are not available there: Alpaca, Binance USD-M and COIN-M futures, Bitfinex, Charles Schwab, Deribit, Gate.io futures, HTX futures and swaps, and Hyperliquid. Because oldest is the default, c=position cm=1 on these stops with "does not support sort method" whenever more than one position matches. Name a sort they do support, such as cmo=lowest or cmo=highest (by entry price), to get past it.
Some exchanges report a short position's size as a negative number, which puts shorts at the small end of smallest and biggest. Check the pick with d=1. Which exchanges close part of a position is covered in partial closes by exchange.
Test it once before you rely on it
Add d=1 to your cancel line. Autoview lists each order it would cancel in your log and cancels nothing, so you can see which ones cm= and cmo= picked. The log guide shows where to look. To narrow a cancel by tag or price instead of by count, see cancel by id=, by exchange and cancel by price (fp=), by exchange.