> 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.

# OrderUpdate

## Definition

**OrderUpdate** can be used for subscribing to order update events.

Remember to unsubscribe if you are no longer using the subscription.

## Syntax

`OrderUpdate`

## Examples

```csharp
/* Example of subscribing/unsubscribing to order update events from an Add On. The concept can be carried over to any NinjaScript object you may be working on. */
public class MyAddOnTab : NTTabPage
{
    private Account account;
    private Order myEntryOrder;
    private Order profitTarget;
    private Order stopLoss;

    public MyAddOnTab()
    {
        // Find our Sim101 account
        lock (Account.All)
            account = Account.All.FirstOrDefault(a => a.Name == "Sim101");

        // Subscribe to order updates
        if (account != null)
            account.OrderUpdate += OnOrderUpdate;
    }

    // This method is fired as the status of an order changes
    private void OnOrderUpdate(object sender, OrderEventArgs e)
    {
        // Submit stop/target bracket orders
        if (myEntryOrder != null && myEntryOrder == e.Order)
        {
            if (e.OrderState == OrderState.Filled)
            {
                string oco = Guid.NewGuid().ToString("N");

                profitTarget = account.CreateOrder(e.Order.Instrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Manual, TimeInForce.Day, 
                    e.Quantity, e.AverageFillPrice + 10 * e.Order.Instrument.MasterInstrument.TickSize, 0, oco, "Profit Target", Core.Globals.MaxDate, null);
                stopLoss = account.CreateOrder(e.Order.Instrument, OrderAction.Sell, OrderType.StopMarket, OrderEntry.Manual, TimeInForce.Day, 
                    e.Quantity, 0, e.AverageFillPrice - 10 * e.Order.Instrument.MasterInstrument.TickSize, oco, "Stop Loss", Core.Globals.MaxDate, null);
                account.Submit(new[] { profitTarget, stopLoss });
            }
        }
    }

    // Called by TabControl when tab is being removed or window is closed
    public override void Cleanup()
    {
        // Make sure to unsubscribe to the orders subscription
        if (account != null)
            account.OrderUpdate -= OnOrderUpdate;
    }

    // Other required NTTabPage members left out for demonstration purposes. Be sure to add them in your own code.
```