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

# GetTrades()

## Definition

Returns a **TradeCollection** object representing all trades that make up the specified position.

## Method Return Value

A **TradeCollection** object.

## Syntax

`\<tradecollection\>.GetTrades(string instrument, string entrySignalName, int instance)`

## Parameters

| Parameter           | Description                                                                                   |
| ------------------- | --------------------------------------------------------------------------------------------- |
| **instrument**      | An instrument name such as "MSFT"                                                             |
| **entrySignalName** | The name of your entry signal                                                                 |
| **instance**        | The occurrence to check for (1 is the most recent, 2 is the 2nd most recent position, etc...) |

## Examples

```csharp
protected override void OnBarUpdate()
{
     TradeCollection myTrades = SystemPerformance.AllTrades.GetTrades("MSFT", "myEntrySignal", 1);
     Print("The last position was comprised of " + myTrades.Count + " trades.");
}
```