Fully Automated Trading: Introducing Entry, Take Profit, and Stop Loss Bracket Orders

Fully automated trading by using TradingView alerts to place entry, take profit, and stop loss bracket orders in NinjaTrader using one webhook alert.

Chart showing bracket order setup with entry, take profit, and stop loss levels.
Fully automated trading now includes single-command bracket orders for entry, take profit, and stop loss.

In addition to a normal PLACE order, you can now enter a take profit level, a stop loss level, or both to create an OCO bracket order from a single TradingView alert. This capability allows for fully automated trading from TradingView to NinjaTrader without the need for ATM (Advanced Trade Management) strategies.

Oh, yeah, and for those of you who are big into ATMs, we've also given you the ability to append some or all of the orders to the same ATM strategy for management in NT8. You're welcome.

How it Works

We've added 2 new options for the PLACE order command: TAKE_PROFIT and STOP_LOSS price levels. Traders now have the option to use either or both at the same time, which results in an OCO (One-Cancels-the-Other) bracket order.

OCO is a conditional order that tells the broker, "if either of these orders executes, please cancel the other one." So, for example, if your take profit level is hit and the order fills, the stop loss order will immediately be canceled.

When CrossTrade receives a request for either TAKE_PROFIT or STOP_LOSS 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, while STOP_LOSS becomes a buy or sell stop market order. Both orders are entered as GTC (Good-til-Canceled).

When both take profit and stop loss prices are present in an alert to CrossTrade, we append a randomized OCO reference ID to the order that ties both orders together as an OCO bracket.

How to Set Take Profit and Stop Loss in an Alert

Adding take profit and stop loss levels to an alert is very simple. As mentioned, it is only available as part of the PLACE order command. Both fields accept numeric values only that represent price level triggers for the order in the underlying.

key=xxxxxxxxxxx;
command=PLACE;
account=sim101;
instrument=ES 09-24;
action=BUY;
qty=1;
order_type=MARKET;
tif=DAY;
take_profit=5600;
stop_loss=5400;

Example of how to set TP/SL bracket in one alert

In the example above, an OCO bracket order will be created for 2 sell orders, a limit sell at 5600 and a stop market at 5400.

Before now, creating this order would require 3 separate PLACE command alert messages from TradingView: one to open the order, one to enter the stop loss, and one to enter the take profit.

If you combine this with FLATTEN_FIRST that's four separate commands combined into one TradingView alert. Not to mention this can also be used in conjunction with self-rate limiting and multi-account orders.

đź’ˇ
TAKE_PROFIT and STOP_LOSS can be used together as an OCO bracket or solo.

Manage Position and Orders using the same ATM Strategy

We thought some of you might also want to group these positions and orders under the same ATM strategy, so we included an extra flag called APPEND_ATM which does exactly as it says.

The APPEND_ATM flag, used in conjunction with a named STRATEGY, will append the take profit and/or stop loss orders to the same strategy instance managing the position that was just opened. To enable it, CrossTrade is looking for a true value in the APPEND_ATM field. Example:

strategy=crosstrade;
append_atm=true;

Appending TP/SL orders to a named ATM Strategy

Showcase of CrossTrade's Capabilities using One TradingView Alert

Here's an example of all of the things now possible using a single alert message:

  1. Flatten existing position in ES 09-24
  2. Place a buy order for +1 ES 09-24 contracts
  3. Set a sell limit order at a predefined price level
  4. Set a sell stop market order at a predefined price level
  5. Create an OCO bracket order between the take profit and stop loss orders
  6. Pass the position and OCO orders to the same ATM strategy
  7. Only allow one similar order like this once every 5 minutes
  8. Send this entire series of orders to three separate accounts in NinjaTrader
key=xxxxxxxxxxx;
command=PLACE;
account=sim101,sim102,sim103;
instrument=ES 09-24;
action=BUY;
qty=1;
order_type=MARKET;
tif=DAY;
flatten_first=true;
take_profit=5600;
stop_loss=5400;
strategy=crosstrade;
append_atm=true;
rate_limit=1/320;
id=autotrade;

Advanced automated trading: 4 NT8 orders generated from 1 TradingView alert

Significance of this Update

For the first time, CrossTrade is enabling fully automated trading using only TradingView and leaving NinjaTrader's responsibilities to just order execution. Something like this was only possible in the past by either sending multiple alerts to NT8 from TradingView (difficult) or by sending a single PLACE order with an ATM strategy appended to it.

The ATM method worked well, but the issue was knowing how and where to set the Take Profit/Stop Loss levels if that information was only known to the chart or indicator inside TradingView.

With this update, traders can now enjoy a seamless trading experience where TradingView handles all the decision-making and analysis, while NinjaTrader executes orders with precision. This reduces complexity, minimizes errors, and enhances the efficiency of automated trading systems.

It's a significant step forward in integrating two trading platforms to deliver both powerful and flexible trading solutions.

Start your free trial

Try CrossTrade for 7 days.

Sign Up