Skip to main content

Examples & Use Cases

Example Alerts & Order Behavior

These examples omit destination, so they route to NinjaTrader 8. Do not make an example portable by appending destination=tradovate; blindly. Check the Destinations capability matrix first because shared command names can have different required fields, broker sequences, and unsupported options.

Buy or Sell with Market Order

This payload will trigger a simple market order for Buy or Sell actions on the continuous futures contract instrument ES1! that will remain in-force for the rest of the trading day.

key=your-secret-key;
command=place;
account=sim101;
instrument=ES1!;
action=buy;
qty=1;
order_type=market;
tif=day;

info

Be aware that if you send a BUY order and then a SELL order using the same quantity, the sell order will offset the buy position. This scenario does not create a net short position.
\ If you want to close an existing position before opening a new position, include "flatten_first=true;" inside your message. More Info on Flatten_First.

Buy or Sell with ATM Strategy

This payload will trigger a simple market order for Buy or Sell actions that will use an ATM strategy template and remain in-force for the rest of the trading day.

key=your-secret-key;
command=place;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
flatten_first=true;
atm_strategy=crosstrade;

warning

Similar to the offsetting scenario when sending a Sell after a Buy, when using an ATM strategy, this will create orphaned Stops and Target orders as those are not cancelled by default. We recommend always using flatten_first=true; with your ATM payload to ensure that any existing bracket is closed completely.

The quantity you set inside of your CrossTrade alert will supersede your default ATM quantity.

Buy or Sell Trade Brackets

Adding take-profit and stop-loss levels or a TP/SL OCO bracket is available on the PLACE and FLATPLACE commands. Each field accepts an absolute numeric price or a supported relative offset such as a percentage, dollar amount, points, or ticks. Relative values require a usable quote, and their resolution path differs by destination. See Percentage and Tick Price Levels.

Numerical example:

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
take_profit=(price above);
stop_loss=(price below);

Tick based example:

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
take_profit=100ticks;
stop_loss=100ticks;

Percentage based example:

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
take_profit=10%;
stop_loss=10%;

Dollar based example:

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
take_profit=$1000;
stop_loss=$1000;

Buy or Sell Limit Orders

This payload will trigger a simple limit order for Buy or Sell actions that will use the specified limit price.

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=limit;
limit_price=X;
tif=day;

If you place a Buy limit order above the current price, or a Sell limit order below, it will be executed immediately as you're crossing the spread.

Stop Market and Stop Limit Orders

This payload will trigger a Stop Market or Stop limit order for Buy or Sell actions that will use the specified stop price.

key=your-secret-key;
command=place**;**
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=stopmarket;
stop_price=X;
tif=day;

You must use the stop_price command and not the limit_price command when submitting Stop Market or Stop Limit order types.

Close then Open (Flatplace)

FLATPLACE clears the position and nonterminal working orders for the same account and instrument, waits for that cleanup to settle, and then submits the new entry. If cleanup cannot be confirmed, the entry is withheld. The intent is shared by both destinations, but NinjaTrader performs it through the Add-On while Tradovate performs a broker-side composite and applies the same settlement barrier separately to mapped copier followers.

key=your-secret-key;
command=flatplace;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;

Close Position

This command will close a position and requires an account name value and an instrument name value. The instrument name value is the name of the NinjaTrader instrument including the exchange name. For equities, the symbol is sufficient. This command will cancel any working orders and flatten the position.

key=your-secret-key;
command=closeposition;
account=sim101;
instrument=ES 09-26;

Close Partial Position

Lets assume you have 4 contracts open, this command would close 2 of 4. Additionally you could use quantity=2; to close 2 of 4:

key=your-secret-key;
command=closeposition;
account=sim101;
instrument=ES 09-26;
quantity=50%;

Close Strategy

This command will close an ATM Strategy and requires a strategy ID value. The strategy ID value must match a strategy ID given to a strategy in the PLACE command. This command will close the specified strategy.

key=your-secret-key;
command=closestrategy;
strategy_id=atm-strategy-id;

Reverse

Unlike Reverse Position, which equates to a close position + entry of a specific new order, Reverse is a true inversion of an existing position.

key=your-secret-key;
command=reverse;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
strategy=crosstrade;

Reverse Position

This command will close the current position and place an order in the opposite direction. The field requirements are identical to the PLACE command.

key=your-secret-key;
command=reverseposition;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
strategy=crosstrade;

When reversing a position with an ATM strategy, you'll want to ensure that a position already exists in the underlying instrument and the action is also the opposite of the existing position you intend to reverse.

Flatten Everything

This command will cancel all active orders and flatten all positions across all accounts and broker connections.

key=your-secret-key;
command=flatteneverything;

Flatten Positions

The FLATTEN positions command is very powerful. It provides the option to flatten all positions and pending orders across all accounts, a specific position for a particular instrument in a certain direction in one account, or anything in between.

key=your-secret-key;
command=flatten;
account=sim101;
instrument=ES 09-26;

Flatten all positions in the sim101 account:

key=your-secret-key;
command=flatten;
account=sim101;

Flatten all short (or long) positions in Sim101:

key=your-secret-key;
command=flatten
account=sim101;
market_position=short;

Flatten all long positions across all NT8 accounts:

key=your-secret-key;
command=flatten;
market_position=long;

Flatten all MNQ 09-26 positions across all NT8 accounts:

key=your-secret-key;
command=flatten;
instrument=MNQ 09-26;

Flatten all MNQ 09-26 positions across all NT8 accounts:

key=your-secret-key;
command=flatten;

info

As you can see the FLATTEN command can be customized for a variety of situations.

Cancel Single Order

This command will cancel an order and requires an order ID value and an optional strategy ID value.

key=your-secret-key;
command=cancel;
order_id=your-order-ID;

You can optionally add strategy_id=your-strategy-id; for a NinjaTrader ATM-owned order. Do not include strategy_id on Tradovate.

Cancel Multiple Orders

Similar to the FLATTEN positions command, CANCELORDERS provides the option to either cancel all orders in an account, or optionally cancel all orders in an account for a specific instrument.

The following alert will cancel all orders in the sim101 account:

key=your-secret-key;
command=cancelorders;
account=sim101;

The following alert will cancel all orders in the sim101 account for instrument ES 09-26:

key=your-secret-key;
command=cancelorders;
account=sim101;
instrument=ES 09-26;

Cancel All Orders

This command will cancel all active orders across all accounts and broker connections.

key=your-secret-key;
command=cancelorders;

Cancel and Replace

CANCELREPLACE is a guarded CANCEL followed by PLACE, not a broker-atomic edit. The replacement is restricted to the original order's account and exact contract. Follow the Cancel Replace command page for destination-specific recovery guarantees.

The following alert requests cancellation of order abc123 and uses the remaining fields for the replacement only after the destination's cancellation requirements are confirmed:

key=your-secret-key;
command=cancelreplace;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
order_id=abc123;

On Tradovate, the operation is owner-fenced and durably staged. CrossTrade confirms cancellation of the leader and every mapped signal-copier follower before placing replacements. An ambiguous cancel or placement outcome is never resent automatically; the response requires reconciliation before a new replacement is attempted.

Change Order

This command changes a pending, unfilled order and requires order_id plus at least one value to modify. NinjaTrader can change quantity and applicable limit/stop prices. Tradovate can also change order type, TIF, expiry, iceberg size, and trailing offset. For a partial Tradovate change, CrossTrade restores omitted quantity, order type, the price fields required by the final order type, and the trailing offset required by a trailing order before submitting the modification. Follower orders restore those fields from their own live versions.

The order_id value must match the order_id you assigned to the order on the original PLACE command.

key=your-secret-key;
command=change;
limit_price=XXX;
order_id=your-order-id;

Include only the values you intend to change. qty, stop_price, and NinjaTrader-only strategy_id are optional fields, but text such as (optional) must not appear inside the webhook payload.