Skip to main content
Attach a take-profit and a stop-loss to an existing position rather than to an order. The pair tracks the position: it carries no size of its own and always exits whatever is open at trigger time, so a position that grows or shrinks afterwards stays covered.

Rate limits

Attach take-profit and stop-loss

Request parameters

Neither side nor amount appears among the parameters. The engine derives both from the open position, which is why the legs come back with amount "0". At least one of the two activation prices must be present — sending neither returns error 1. Supplying only one arms a take-profit or a stop-loss on its own. On a long position the take-profit trigger sits above the market and the stop-loss below; a price on the wrong side returns error 105 or 106.

Response

The result object holds the take_profit and stop_loss legs, each reporting type 10. See the order object reference. In the example both legs show side 1 — a sell closes a long position — and amount "0", meaning whatever the position holds when the trigger fires.
An open position is required. Without one the call fails with error 104, so arm the pair after the entry fills rather than alongside it. For an entry that arms its own exit in a single request, use collateral_order_oto_place instead.
Each call is additive. Every request creates a new pair of TP/SL orders. It does not replace or cancel the TP/SL orders already on the position, including those created through the REST API (takeProfit / stopLoss parameters) or by OTO orders. Calling the method twice leaves two pairs armed.

Change TP/SL levels

Two approaches move the levels of existing TP/SL orders:
  1. Modify the existing legs with order_modify, for example to change the activation price.
  2. Cancel the existing legs with order_cancel, then place a new pair with collateral_order_tpsl_place.

Behavior on position close

When a TP/SL order triggers and closes the position, the remaining TP/SL orders for that position are cancelled automatically.
The two legs are independent orders with separate ids, so cancel each one with order_cancel. A TPSL pair has no group id, so order_cancel_conditional does not apply. TPSL legs can be modified with order_modify.

Error codes

Standard transport errors and the shared account, rate-limit, and region codes are listed in Order Management.