Close & Cancel
Seven fields. Close = flat an existing position. Cancel = remove pending orders. Two different jobs that often happen together but are independently controlled.
closeCurrentPosition: true— close the open position on the pair, any direction (one-way mode).closeLong: true/closeShort: true— hedge-mode helpers; close one side only.cancelAllOrders: true— cancel every pending order on the pair (entries, DCA, TP, SL).cancelAllDcaOrders: true— cancel just the DCA mesh; leave TP/SL intact.- Standalone variants
cancelAllandcancelAllDcaexist for "no-op-payload-that-just-cancels" use cases.
All fields on this page are booleans. No placeholders.
Quick reference table
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
closeCurrentPosition | bool | no | false | Close the open position on the pair, regardless of direction. Combine with useLimitClose for a non-market exit. |
cancelAllDcaOrders | bool | no | false | Not an immediate cancel. A companion flag stored with the trade's trailing-stop record; when the trailing stop later closes the position, TVH also cancels the pair's remaining pending orders. Only meaningful alongside a trailing stop. For an immediate DCA-mesh cancel use cancelAllDca. |
cancelAllOrders | bool | no | false | Cancel every open order on the pair (entries, DCA legs, TP, SL). Useful as a reset before a fresh setup. |
closeLong | bool | no | false | Hedge-mode helper: close only the long side. Required when the account is in dual-position mode and you want to flat one direction. |
closeShort | bool | no | false | Hedge-mode helper: close only the short side. |
cancelAllDca | bool | no | false | Standalone trade command that cancels the pair's DCA mesh limit orders (TP/SL stay attached) and does nothing else. This is the field that actually clears a pending mesh immediately. |
cancelAll | bool | no | false | Standalone command to cancel every pending order on the pair. Counterpart to cancelAllOrders when no entry is included. |
Close vs cancel — conceptual difference
| Term | What it does |
|---|---|
| Close | Flatten an existing position with an opposite-side market or limit order sized to whatever's open. A full close also cancels the pair's remaining pending orders (TP/SL, DCA legs, unfilled entries). |
| Cancel | Remove a pending order that hasn't filled yet. Does not affect the existing position. |
A full close already cleans up. After flattening the position, a market close cancels every pending order left on the pair automatically — you do not need a separate cancelAllOrders alongside it. Two exceptions: a partial close (usePartialClose) keeps the existing take-profit orders and resizes them to the reduced position instead of cancelling, and a limit close (useLimitClose) leaves orders in place until the limit fills.
The two operations can also fire in the same payload. When you include explicit cancel flags with an entry, the order on the exchange is cancel first, then trade — TVH clears the order book first so the new order doesn't fight stale TPs/SLs.
Closing a position
One-way mode close (default Binance Futures, Bybit, OKX net)
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isClose": true,
"token": "<token>"
}
The auto-mapping logic (Anatomy → orderType auto-mapping) sets isClose=true, isMarket=true and disables chaseLimitOrder (unless useLimitClose=true). TVH then submits an opposite-side market order sized to the current position.
The longer form using the explicit flag:
{
"closeCurrentPosition": true
}
Both achieve the same thing in one-way mode. closeCurrentPosition: true is preferred when you want to combine it with other actions in the same payload (e.g. flip-to-opposite):
{
"isBuy": true,
"closeCurrentPosition": true,
"units": 0.05
}
Closes the existing short (if any) then opens a fresh long. The classic "flip" pattern.
Hedge-mode close (Binance Futures dual-position)
In hedge mode, closeCurrentPosition is ambiguous — which side? Use the helpers:
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isClose": true,
"closeLong": true,
"hedgeMode": true,
"token": "YOUR_TOKEN"
}
Closes the long side. The short, if any, stays open.
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isClose": true,
"closeShort": true,
"hedgeMode": true,
"token": "YOUR_TOKEN"
}
Closes the short side only.
Auto-reset rule: TVH's auto-mapping resets closeLong=false when orderType="buy" (assuming you mean a fresh long entry) and resets closeShort=false when orderType="sell". This prevents an entry payload from accidentally also closing the opposite side. Override by pairing with strategyCloseValue and a matching strategyComment — see Anatomy → strategyComment auto-close.
Flip with limit close
{
"isClose": true,
"closeCurrentPosition": true,
"useLimitClose": true,
"isLimit": true,
"price": 65500
}
Exit at limit price 65500 instead of market. Requires useLimitClose: true — see Limit Order Management → useLimitClose.
Cancel cascade
Three flags cancel orders when the payload runs. A fourth, cancelAllDcaOrders, is not an immediate cancel — see the note below.
| Flag | What gets cancelled | What survives |
|---|---|---|
cancelAllOrders | Every open order on the pair (entries, DCA legs, TP, SL) | Nothing |
cancelAll | Every open order on the pair, as a standalone payload | Nothing |
cancelAllDca | DCA mesh limits only, as a standalone payload | TP, SL, unrelated entry limits |
cancelAllOrders is designed to combine with an entry or close in the same payload (cancel first, then trade). cancelAll and cancelAllDca are standalone "no-op except for the cancel" payloads.
cancelAllDcaOrders is not an immediate cancelDespite the name, the cancelAllDcaOrders flag cancels nothing when the payload is processed. It is stored with the trade's trailing-stop record and tells TVH to cancel the pair's remaining pending orders later, at the moment the trailing stop closes the position. It only has an effect alongside a trailing stop. To clear a DCA mesh now, use cancelAllDca.
Cancel-then-trade
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isBuy": true,
"isMarket": true,
"units": 0.05,
"cancelAllOrders": true,
"token": "<token>"
}
Cancel every pending order first (stale entries, leftover SLs, half-filled DCA), then open a fresh long. Useful as the first leg of a new setup when the pair has had previous activity.
Cancel-only payload
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"cancelAll": true,
"token": "<token>"
}
No orderType. No units. Just "clear the slate on this pair". TVH does nothing else.
Cancel just the DCA mesh
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"cancelAllDca": true,
"token": "<token>"
}
The DCA mesh from a previous payload is cancelled. TP and SL on the already-filled portion stay attached.
Detail per property
closeCurrentPosition
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
Close the open position on the pair, regardless of direction. Combine with useLimitClose for a non-market exit, or with an entry payload for a flip.
closeLong
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
| Auto-mapped | yes — kept only when the command resolves to a sell (orderType="sell"); otherwise reset to false |
Hedge-mode helper. Close only the long side.
closeShort
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
| Auto-mapped | yes — kept only when the command resolves to a buy (orderType="buy"); otherwise reset to false |
Hedge-mode helper. Close only the short side.
cancelAllDcaOrders
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
Not an immediate cancel. A companion flag stored with the trade's trailing-stop record. When the trailing stop later closes the position, TVH also cancels the pair's remaining pending orders. Only meaningful when a trailing stop is attached. For an immediate DCA-mesh cancel use cancelAllDca.
cancelAllOrders
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
Cancel every open order on the pair (entries, DCA legs, TP, SL). Combine with an entry to clear the book before re-entering.
cancelAllDca
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
Standalone payload that cancels the DCA mesh limits on the pair (TP and SL stay attached) and does nothing else. This is the field that actually clears a pending mesh now.
cancelAll
| Attribute | Value |
|---|---|
| Type | bool |
| Required | no |
| Default | false |
Standalone variant of cancelAllOrders. Use as a maintenance payload that touches only pending orders.
Worked examples
Reverse position (flip long to short)
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"isSell": true,
"closeCurrentPosition": true,
"isMarket": true,
"units": 0.05,
"stopLossType": "percent",
"stopLossPercent": 1.5,
"token": "<token>"
}
If long is open, it's closed first. Then a fresh 0.05 BTC short opens with a 1.5% SL. The Activity Log shows two fills for this payload (the close, then the entry).
Reset before a fresh setup
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"cancelAll": true,
"token": "<token>"
}
Then a separate payload to open the new entry. Two payloads is cleaner than one because the cancel and the entry happen at different cadences.
Hedge-mode flat the long, keep the short
{
"exchange": "binance-futures",
"pair": "BTCUSDT",
"apiKey": "binance-futures-main",
"hedgeMode": true,
"isClose": true,
"closeLong": true,
"token": "<token>"
}
Long is closed at market. Short stays open with its own SL/TP intact.
Common mistakes
closeCurrentPosition: truein hedge mode. Ambiguous — Binance ignores it in dual-position mode. UsecloseLong/closeShort.cancelAllOrders: trueon a payload with TP/SL. Cancels the brand-new TP/SL you just attached if the cancel runs after the entry's TP/SL placement. UsecancelSlOrders(for SL only) or split into two payloads if you want surgical control. See Stop Loss → cancelSlOrders.closeCurrentPosition: truewith no position open. No-op. TVH logs "no position to close" and the rest of the payload (if any) executes.- Cancel + close in the wrong order assumption. TVH cancels first, then closes. If you sent
cancelAll: trueandcloseCurrentPosition: true, the cancel removes pending TPs/SLs before the close goes through — which is normally what you want, but means there's a microsecond window where the position is naked. Most exchanges accept this fine.
Next
Timing & Idempotency — alertTimestamp dedup, delay, retries.