CrossTrade Docs
Basic CommandsAdvanced Commands
  • Welcome!
    • Set Up Guide
  • Getting Started
    • Installation
    • User Dashboard
      • XT Control Panel
      • Manual Trader
      • Command Builder
    • Alert History
    • TradingView Alerts
      • Dynamic Variables
      • XT Alert Builder
      • Example Indicators
      • Example Strategies
    • VPS Connection Guide
  • Webhooks
    • Overview
    • Commands
      • Place Order
      • Flat Place Order
      • Close Position
      • Reverse
      • Reverse Position
      • Flatten Positions
      • Flatten Everything
      • Cancel Order
      • Cancel Orders
      • Cancel All Orders
      • Cancel Replace
      • Change Order
      • Close Strategy
    • Advanced Options
      • Multi-Account Placement
      • Flatten First
      • Require Market Position
      • Max Positions
      • Bracket Orders
      • Percentage and Tick Prices
      • Limit Order Timeouts
      • Trading Window
      • Bypass Trade Windows
      • Delay Timer
      • Rate-Limiting
      • Alert Commenting
      • Kill Switch
      • Notes
    • Examples & Use Cases
    • Troubleshooting
  • Account Manager
    • Overview
      • How It Works
      • Dashboard
      • Global Settings
      • Frequently Asked Questions (FAQ)
    • Monitors
      • Profit/Loss Thresholds
      • Minimum Profit Drawdown
      • Trailing Drawdown
      • Advanced Usage
    • Account Settings
      • Auto-Flattening
      • Trading Windows
    • Management Logs
  • NinjaTrader
    • ATM Strategies
      • Creating ATM Template
    • Optimizing NinjaTrader Performance
    • Enabling Multi-Provider Mode
  • CrossTrade API
    • Overview
    • Authentication
    • Rate Limiting
    • Webhook Trading
    • Accounts
      • GET Accounts Summary
      • GET Accounts
      • GET Account
    • Positions
      • GET Positions
      • GET Position
      • POST Close Position
      • POST Reverse
      • POST Reverse Position
      • POST Flatten Positions
      • POST Flatten Everything
    • Orders
      • GET Orders
      • GET Order
      • GET Order Status
      • POST Cancel Order
      • POST Cancel Orders
      • POST Cancel All Orders
      • POST Place Order
      • POST Flat Place Order
      • POST Replace Order
      • PUT Change Order
    • Strategies
      • GET Strategies
      • GET Strategy
      • POST Close Strategy
    • Executions
      • GET Executions
      • GET Execution
    • Quotes
      • GET Quote
  • Changelog
    • XT Versions
    • All Updates
  • Affiliate Program
    • Media Kit
  • Social Links
    • Discord
    • TradingView
    • YouTube
    • X (Twitter)
    • Instagram
    • Facebook
    • Reddit
    • Website
    • Blog
Powered by GitBook
On this page
  • One-sided TP/SL Order
  • Two-sided TP/SL OCO Bracket Order
  • Appending to an ATM Strategy
  • Example Payloads
  1. Webhooks
  2. Advanced Options

Bracket Orders

PreviousMax PositionsNextPercentage and Tick Prices

Last updated 1 month ago

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 ( to the underlying for TP/SL can also be used, such as % and tick values).

The Automated Trading Interface (ATI) must be enable for this feature to work correctly.

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=ES 06-25; 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=ES 06-25; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above); stop_loss=(price below);

The value used for the stop_loss requires a negative sign to offset properly on the price scale. Example: stop_loss=-100ticks;

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=ES 06-25; 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=ES 06-25; 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=ES 06-25; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=(price above); stop_loss=(price below); strategy=crosstrade; append_atm=true;

To add stops and targets in Ticks or Percentages, simply replace the numerical value. Tick Example: key=your-secret-key; command=PLACE; account=sim101; instrument=ES 06-25; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=100 ticks; stop_loss=-100 ticks; Percentage Example: key=your-secret-key; command=PLACE; account=sim101; instrument=ES 06-25; action=BUY; qty=1; order_type=MARKET; TIF=DAY; take_profit=5%; stop_loss=-5%;

relative prices
Learn more