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

# AverageTimeInMarket

## Definition

Returns the average duration of a trade weighted by quantity.

## Property Value

A TimeSpan value that represents the quantity-weighted average duration of a trade.

## Syntax

`TradesPerformance.AverageTimeInMarket`

## Examples

```csharp
protected override void OnBarUpdate()
{
     // Print out the quantity-weighted average duration of all trades
     Print("Average time in market: " + SystemPerformance.AllTrades.TradesPerformance.AverageTimeInMarket);
}
```