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

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 account-level working or pending orders and flatten the position if the position exists.

It is important to note that open or pending orders will not be canceled unless a position already exists that can be closed.

Advanced Usage - Scaling out

The generic CLOSEPOSITION command will close the entire position. It is also possible to scale out of a position by specifying the quantity or percent of contracts that should be closed.

The percentage of contracts to be closed is specific as a decimal number between 0 and 1. For example, percent=0.25; would be used to close 25% of the remaining contracts.

Percentages are always rounded up. So 10% of 1 remaining contract will close 1 contract. Quantities will close up to the remaining contract quantity. So if quantity=4; with 1 remaining contract, the 1 contract will be closed.

If both quantity and percent appear in the alert payload, quantity will take priority and percent will be ignored.

Quantity and percent must always be greater than zero.

Example Payloads

Close the entire ES 06-25 positions in account Sim101.

key=your-secret-key;
command=CLOSEPOSITION;
account=Sim101;
instrument=ES 06-25;

Close 2 contracts of however many are remaining in account Sim101:

key=your-secret-key;
command=CLOSEPOSITION;
account=Sim101;
instrument=ES 06-25;
quantity=2;

Close 50% of the remaining contracts in account Sim101:

key=your-secret-key;
command=CLOSEPOSITION;
account=Sim101;
instrument=ES 06-25;
percent=0.5;

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.

PreviousFlat Place OrderNextReverse

Last updated 1 month ago