> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Order

## Definition

Represents a read only interface that exposes information regarding an order.

* An Order object returned from calling an order method is dynamic in that its properties will always reflect the current state of an order.
* The property **\<order>.OrderId** is NOT a unique value, since it can change throughout an order's lifetime. Please see the [Advance Order Handling](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/advanced-order-handling) section on "Transitioning order references from historical to live" for details on how to handle.
* The property **\<order>.Oco** WILL be appended with a suffix when the strategy transitions from historical to real-time to ensure the OCO id is unique across multiple strategies for live orders.
* To check for equality you can compare Order objects directly.

## Methods and Properties

| Parameter            | Description                                                                                                                                                                                                                                                                                                                                               |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Account              | The [Account](/developer/desktop-sdk/references/add-on/account-class) the order resides                                                                                                                                                                                                                                                                   |
| AverageFillPrice     | A double value representing the average fill price of an order                                                                                                                                                                                                                                                                                            |
| Filled               | An int value representing the filled amount of an order                                                                                                                                                                                                                                                                                                   |
| FromEntrySignal      | A string representing the user defined fromEntrySignal parameter on an order                                                                                                                                                                                                                                                                              |
| Gtd                  | A [DateTime](http://msdn2.microsoft.com/en-us/library/system.datetime.aspx) structure representing when the order will be canceled                                                                                                                                                                                                                        |
| HasOverfill          | A bool value representing if the order is an overfill. For use when using [Unmanaged orders](/developer/desktop-sdk/references/strategy/order-methods/unmanaged-approach) and [IgnoreOverFill](/developer/desktop-sdk/references/strategy/order-methods/unmanaged-approach/ignoreoverfill)                                                                |
| Instrument           | An [Instrument](/developer/desktop-sdk/references/common/instrument) value representing the instrument of an order                                                                                                                                                                                                                                        |
| IsBacktestOrder      | A bool that indicates if the order was generated while processing historical data. For use with [GetRealtimeOrder()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/getrealtimeorder) when transitioning historical order objects to live order objects when strategies transition to from State.Historical to State.Realtime. |
| IsLiveUntilCancelled | A bool that when true, indicates the order will be canceled by [managed order handling](/developer/desktop-sdk/references/strategy/order-methods/managed-approach) at expiration                                                                                                                                                                          |
| IsTerminalState()    | A static method used to determine if the an order's OrderState is in considered terminal and no longer active                                                                                                                                                                                                                                             |
| LimitPrice           | A double value representing the limit price of an order                                                                                                                                                                                                                                                                                                   |
| LimitPriceChanged    | A double value representing the new limit price of an order. Used with [Account.Change()](/developer/desktop-sdk/references/add-on/account-class/change)                                                                                                                                                                                                  |
| Name                 | A string representing the name of an order which can be provided by the entry or exit signal name                                                                                                                                                                                                                                                         |
| Oco                  | A string representing the OCO (one cancels other) id of an order                                                                                                                                                                                                                                                                                          |
| OrderAction          | Represents the action of the order. Possible values are:<br />• OrderAction.Buy<br />• OrderAction.BuyToCover<br />• OrderAction.Sell<br />• OrderAction.SellShort                                                                                                                                                                                        |
| OrderId              | A string representing the broker issued order id value (this value can change)                                                                                                                                                                                                                                                                            |
| OrderState           | The current state of the order. See the order state values table below                                                                                                                                                                                                                                                                                    |
| OrderType            | The type of order submitted. Possible values are:<br />• OrderType.Limit<br />• OrderType.Market<br />• OrderType.MIT<br />• OrderType.StopMarket<br />• OrderType.StopLimit                                                                                                                                                                              |
| Quantity             | An int value representing the quantity of an order                                                                                                                                                                                                                                                                                                        |
| QuantityChanged      | An int value representing the new quantity of an order. Used with [Account.Change()](/developer/desktop-sdk/references/add-on/account-class/change)                                                                                                                                                                                                       |
| StopPrice            | A double value representing the stop price of an order                                                                                                                                                                                                                                                                                                    |
| StopPriceChanged     | A double value representing the new stop price of an order. Used with [Account.Change()](/developer/desktop-sdk/references/add-on/account-class/change)                                                                                                                                                                                                   |
| Time                 | A [DateTime](http://msdn2.microsoft.com/en-us/library/system.datetime.aspx) structure representing the last time the order changed state                                                                                                                                                                                                                  |
| TimeInForce          | Determines the life of the order. Possible values are:<br />• TimeInForce.Day<br />• TimeInForce.Gtc                                                                                                                                                                                                                                                      |
| ToString()           | A string representation of an order                                                                                                                                                                                                                                                                                                                       |

## OrderState Values

| Order State                | Description                                                                    |
| -------------------------- | ------------------------------------------------------------------------------ |
| OrderState.Initialized     | Order is initialized in NinjaTrader                                            |
| OrderState.Submitted       | Order is submitted to the broker                                               |
| OrderState.Accepted        | Order is accepted by the broker or exchange                                    |
| OrderState.TriggerPending  | Order is pending submission                                                    |
| OrderState.Working         | Order is working in the exchange queue                                         |
| OrderState.ChangePending   | Order change is pending in NinjaTrader                                         |
| OrderState.ChangeSubmitted | Order change is submitted to the broker                                        |
| OrderState.CancelPending   | Order cancellation is pending in NinjaTrader                                   |
| OrderState.CancelSubmitted | Order cancellation is submitted to the broker                                  |
| OrderState.Cancelled       | Order cancellation is confirmed by the exchange                                |
| OrderState.Rejected        | Order is rejected                                                              |
| OrderState.PartFilled      | Order is partially filled                                                      |
| OrderState.Filled          | Order is completely filled                                                     |
| OrderState.Unknown         | An unknown order state. Default if broker does not report current order state. |

Critical: In a historical backtest, orders will always reach a "Working" state. In real-time, some stop orders may only reach "Accepted" state if they are simulated/held on a brokers server.

## Examples

```csharp
private Order entryOrder = null;
  
protected override void OnBarUpdate()
{
   if (entryOrder == null && Close[0] > Open[0])
       EnterLong("myEntryOrder");
}
  
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
   // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
   // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
   if (order.Name == "myEntryOrder")
      entryOrder = order;
  
   if (entryOrder != null && entryOrder == order)
   {
       Print(order.ToString());
       if (order.OrderState == OrderState.Filled)
           entryOrder = null;
   }
}
```