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

# OnMarketData()

## Definition

Called and guaranteed to be in the correct sequence for every change in level one market data for the underlying instrument. The OnMarketData() method updates can include but is not limited to the bid, ask, last price and volume.

## Method Return Value

This method does not return a value.

## Syntax

`protected override void OnMarketData(MarketDataEventArgs marketDataUpdate) \{ \}`

## Parameters

| Parameter        | Description                                                                                                                               |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| marketDataUpdate | A [MarketDataEventArgs](/developer/desktop-sdk/references/common/onmarketdata/marketdataeventargs) representing the change in market data |

## Examples

```csharp
protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
{
  if (marketDataUpdate.MarketDataType == Data.MarketDataType.Last)
  {
    // Do something
  }
}
```