Rate limits
Attach take-profit and stop-loss
Request parameters
Neitherside 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
Theresult 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.
Change TP/SL levels
Two approaches move the levels of existing TP/SL orders:- Modify the existing legs with
order_modify, for example to change the activation price. - Cancel the existing legs with
order_cancel, then place a new pair withcollateral_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.