Flatten First
A PLACE order command with the flatten_first flag enabled is the most popular alert type at CrossTrade, and for good reason.
Flatten first tells CrossTrade that you want to preempt the PLACE order command with a CLOSEPOSITION command for the same account and instrument.
When flatten_first=true, CrossTrade will first send the CLOSEPOSITION command, which flattens any existing positions or open orders for the underlying instrument. Regardless of whether or not a position existed, the PLACE order command will then proceed.
This behavior is contrast to the REVERSEPOSITION command, which will only proceed with the new order instructions if and only if a position already exists in the underlying instrument.
Flatten first is useful for peace of mind to ensure you are always entering the market flat.
Important Note: flatten_first will cancel open or pending orders in the account even if a position does not exist that can be flattened. This behavior is distinctly different from a CLOSEPOSITION or FLATTEN command.
flatten_first also works on the Tradovate destination. The flatten step uses Tradovate's server-side liquidation, which cancels working orders and offsets any open position, then the entry proceeds. See Destinations for the full NinjaTrader and Tradovate capability comparison.
Example Payload
The following command will close any positions or orders in ES 09-26 under the sim101 account before proceeding with the market buy for 1 contract:
key=your-secret-key;
command=place;
account=sim101;
instrument=ES 09-26;
action=buy;
qty=1;
order_type=market;
tif=day;
flatten_first=true;