Bracket Orders

Adding take profit and stop loss levels or TP/SL OCO bracket to an alert is very simple and is only available as part of the PLACE or FLATPLACE order commands. Both fields accept numeric values only that represent price level triggers for the order in the underlying (relative prices to the underlying for TP/SL can also be used, such as % and tick values).

One-sided TP/SL Order

When CrossTrade receives a request for a take_profit, stop_loss, stop_loss_limit, or stop_loss_stop price inside of a place order message, it creates an opposing order (buy becomes sell and vice versa, same quantity, etc.).

  • take_profit becomes a buy or sell limit order to guarantee the profit target is hit

  • stop_loss becomes a buy or sell stop market order

All orders are entered as GTC (Good-til-Canceled).

Alternatively, stop_loss_limit can be used in place of stop_loss. stop_loss_limit creates a stop limit order instead of a stop market order.

A stop limit order is a stop loss level composed of 2 parts: the stop trigger and the limit price. When the stop price is breached the order at the limit price is created.

When using stop_loss_limit orders alone, please be aware that, by default, the stop price and limit price are being set as the same value. In fast moving markets, there's a chance the underlying price can quickly move beyond the the limit price before it has a chance to trigger and close the position.

To explicitly set the stop price of the stop limit order, you can optionally include a stop_loss_stop price level that will act as the initiator or trigger of the limit order. stop_loss_stop must be used in conjunction with stop_loss_limit, otherwise its presence will be ignored. Please see examples on how to use stop losses below.

Two-sided TP/SL OCO Bracket Order

If both take_profit and stop_loss or stop_loss_limit are included in the alert message, it will automatically become an independent OCO bracket order. If the position is closed by means other than the take profit or stop loss orders, the bracket remains active.

When submitting a TP/SL bracket, only one of stop_loss or stop_loss_limit is allowed in the alert message. If both are present, stop_loss takes priority and will be accepted over stop_loss_limit, which is ignored.

Appending to an ATM Strategy

It's possible to append take_profit and/or stop_loss/stop_loss_limit to an ATM strategy for management. To do so, you must indicate the strategy name with the optional flag append_atm=true; This will move the TP/SL order(s) under the ATM strategy for management. If the position or strategy is closed, all related positions and orders will be closed or canceled.

Example Payloads

Generic market order with take profit level set:

key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above);

Market order with both a take profit limit and stop loss level set, which gets converted into an OCO bracket automatically:

key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above); stop_loss=(price below);

Limit order with both a take profit limit and stop loss limit level set, which gets converted into an OCO bracket automatically. This variation sets a stop limit order instead of a stop market order. In this case, the stop price level and the limit price value of the stop limit order are equal to the stop_loss_limit price:

key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=LIMIT; limit_price=X (price below market); TIF=DAY; take_profit=(price above); stop_loss_limit=(price below);

Market order with both a take profit limit and stop loss limit level set, which gets converted into an OCO bracket automatically. In this version, we are explicitly setting the level of the stop price that triggers the order for the stop loss limit price:

key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above); stop_loss_stop=(price below); stop_loss_limit=(price below stop);

Finally, a market order with TP/SL OCO bracket order appended to an ATM strategy called "crosstrade":

key=your-secret-key; command=PLACE; account=sim101; instrument=NQ 12-24; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above); stop_loss=(price below); strategy=crosstrade; append_atm=true;

Learn more...

Last updated