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
    • Intro to NT8
    • 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
  • Checking Multiple Market Positions
  • Example Payloads
  1. Webhooks
  2. Advanced Options

Require Market Position

The flag require_market_position is available to any command with both an account and instrument field. It blocks and prevents the signal from going through unless the NT8 market position is:

  • flat

  • short

  • long

  • flat or long

  • short or long

  • long or short

Require market position is available to any of the following command types:

  • PLACE

  • FLATPLACE

  • CANCELREPLACE

  • CANCELORDERS

  • CLOSEPOSITION

  • REVERSEPOSITION

  • FLATTEN

Checking Multiple Market Positions

In addition to the standard long, short, flat market positions, we've included the ability to check for 2 of the 3 conditions. That is, if any one of 2 conditions are true, the signal won't be blocked.

The use case here is if you want to add to a position in a certain direction, but only if you're already long or flat in that direction. For example, if you are long +3 contracts and you want to add +1 contracts, you want to ensure you are either long or flat in that direction already. Otherwise, if you're short, you would only be making your position "less short" by closing 1 contract.

To check for the "long or flat" conditions, separate the values with a comma. CSV values represent an "or" condition between them: "flat or long", "long or short", etc. They can be in any order: "flat,long", "long,flat", etc.

An example command would be:

key=your-secret-key;
command=PLACE;
account=sim101;
instrument=ES 06-25;
action=BUY;
qty=1;
order_type=MARKET;
tif=DAY;
require_market_position=long,flat;

which translates to buy +1 ES 06-25 at market if and only if a position already exists in ES 06-25 that is flat or long. If a short position is open, block the signal.

Example Payloads

In the simplest case, a PLACE command with require_market_position=flat; for account "sim101" and instrument "ES 06-25" will not be processed unless there's no preexisting position in ES 06-25 under account sim101. The position must be flat for the order to proceed:

key=your-secret-key; command=PLACE; account=sim101; instrument=ES 06-25; action=BUY; qty=1; order_type=MARKET; TIF=DAY; require_market_position=flat;

Let's say you have multiple alert types in play: Long Entry, Long Exit, Short Entry, Short Exit. You don't want to process the "Short Exit" signal to close if there's a long position already in play. In this instance, you could require the alert to be processed if and only if the current market position is short:

key=your-secret-key; command=CLOSEPOSITION; account=sim101; require_market_position=short;

key=your-secret-key; command=PLACE; account=sim101; instrument=ES 06-25; action=SELL; qty=1; order_type=MARKET; tif=DAY; require_market_position=flat,short;

PreviousFlatten FirstNextMax Positions

Last updated 2 months ago

Similar to our example in the section above, if we want to sell short an "ES 06-25" contract if and only if the exist position in the "sim101" account is flat or short:

Multiple Market Positions