Skip to content

How brackets work#

A "bracket" is the set of resting protective orders that surround an open position.

What's placed on entry#

After the MARKET entry order fills and HookTrader has captured the fill price, it places:

Order Type Trigger Qty Notes
SL STOP_MARKET reduceOnly sl price Full entry qty One per trade.
TPs TAKE_PROFIT_MARKET reduceOnly Each tps[i] price The qty implied by reduce_position percent, or the full remaining qty for close_position Up to 8 intermediate pre-staged + 1 final tp_max.

Pre-staging means the action's reduction fires the moment Binance's matching engine sees the trigger price, instead of waiting for HookTrader to receive a tick, decide, and round-trip a market order.

When pre-staging is skipped#

A TP level is pre-staged only if its action list starts with reduce_position or close_position. If the first action is move_sl_be, activate_trail, cancel_algo_orders, etc., the level is handled by the autonomous monitor when the price actually crosses.

TP levels 9+ never pre-stage — Binance caps the number of resting algo orders per symbol, and HookTrader budgets that cap (max 8 intermediates + 1 tp_max) to leave room for the SL.

After a partial close#

When a reduce_position action runs (either from pre-staged algo fill or from a webhook), HookTrader:

  1. Records the close fill as a trade leg.
  2. Updates the remaining position size.
  3. Does not automatically resize the remaining SL — the resting SL was sized to entry qty, and reduce_position is a partial close, so the resting SL is already over-sized (Binance silently clamps reduceOnly fills to the remaining position).

A subsequent move_sl_* action will cancel-and-replace the SL with a freshly-sized order. Otherwise the original SL continues to protect the remaining position correctly.

After a scale-in (add_to_position)#

The Binance SL was sized to the original entry qty. After a scale-in, the resting SL only protects the original position — the added qty is unprotected until the next move_sl_* action runs.

Always pair add_to_position with a move_sl_* action in the same TP level. See Strategies → Actions → add_to_position.

Modifying SL#

A move_sl_* action does a cancel-and-replace:

  1. Cancel the existing STOP_MARKET algo.
  2. Place a new STOP_MARKET sized to current remaining qty at the new trigger.

If the cancel succeeds but the replace fails, HookTrader retries — and if the position is left without a stop, the autonomous monitor's emergency-close logic kicks in.

Bracket lifecycle#

  • Trade closed normally (TP / trail / close_position) — outstanding TP algos are cancelled as a final cleanup step. The trade is marked closed.
  • Trade stopped (SL hit) — outstanding TP algos are cancelled. Trade marked stopped.
  • Emergency close — HookTrader places a reduceOnly MARKET against the full position, then cancels everything. Trade marked stopped with reason emergency.

Each step records a trade leg, except SL-move and trail-activation actions (which don't create orders that produce fills). See Strategies → TP levels → Recording.