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
  • Advanced Usage
  • Example Payloads
  1. Webhooks
  2. Commands

Flatten Positions

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

The FLATTEN command accepts several parameters:

  • account

  • instrument

  • market_position (long, short)

  • nothing

The parameters act as filters, searching for positions that match the criteria to be flattened.

Most importantly, if you execute command=FLATTEN; without any other filters, it is similar to the FLATTENEVERYTHING command. All positions will be closed. The only difference is FLATTENEVERYTHING will close all positions and all orders across all accounts.

If FLATTEN is executed with both an account and an instrument it will be equivalent to a generic CLOSEPOSITION command.

Advanced Usage

If no account is specified, but an instrument and/or market_position is provided, FLATTEN will exit all positions across all accounts that match that criteria.

Example Payloads

Flatten all MES 06-25 positions in Sim101 account (CLOSEPOSITION equivalent):

key=your-secret-key;
command=FLATTEN;
account=Sim101;
instrument=MES 06-25;

Flatten all positions in the Sim101 account:

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

Flatten all short 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=short;

Flatten all MNQ 06-25 positions across all NT8 accounts:

key=your-secret-key;
command=FLATTEN;
instrument=MNQ 06-25;

Flatten all positions in all accounts:

key=your-secret-key;
command=FLATTEN;
PreviousReverse PositionNextFlatten Everything

Last updated 1 month ago