Place OCO
Place an OCO (one-cancels-the-other) order strategy.
Available to: All authenticated users
Environments: Demo, Live
Rate Limit: 1,500 requests per hour, 1-second back-off, counts all requests
An OCO strategy links two orders so that when one fills, the other is automatically cancelled — commonly used to pair a take-profit with a stop-loss. Provide the primary order’s fields (account, action, symbol, orderQty, orderType, and the price fields its type requires), plus an other object describing the linked order. The other order’s own action and orderType determine which price fields it needs. On success, the response includes both an orderId and an ocoId.
Set isAutomated to true for any order placed by code or an automated process, and false only for an order a human places directly. Misreporting this can violate exchange policies.
As with any order, acceptance is subject to market, exchange, and risk-management rules. When rejected, the response carries a failureReason and failureText.
Common Failure Scenarios
- A risk limit blocks the order (for example,
MaxPosLimitReached). - A contract or price is invalid (
InvalidContract,InvalidPrice). - The trading session is closed (
SessionClosed).
Error Messages
See the failureReason enum in the response schema for the complete list of values.
Authentication
Bearer authentication of the form Bearer <token>, where token is your auth token.
Request
Operator ID for the order. Send it only if NinjaTrader configured an allow-list of operator IDs for your user. In that case it’s required on every order and must exactly match one approved value. If no allow-list is configured, omit it: a supplied value is denied. Organizations using passthrough also omit it, and NinjaTrader fills it in. Up to 64 characters. See Operator ID (customTag50) and Passthrough.