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

# PerformanceMetrics

## Definition

Holds an array of **PerformanceMetrics** objects that represent custom metrics that can be used for strategy calculations.

Index value is based on the array of Bars objects added via the **AddPerformanceMetric** method.

## Property Value

An array of **PerformanceMetrics** objects.

## Syntax

`PerformanceMetrics[int index]`

## Examples

```csharp
// Define a new SampleCumProfit object
NinjaTrader.NinjaScript.PerformanceMetrics.SampleCumProfit myProfit;
protected override void OnStateChange()
{
   if (State == State.Configure)
   {
     // Instantiate myProfit to a new instance of SampleCumProfit
     myProfit = new NinjaTrader.NinjaScript.PerformanceMetrics.SampleCumProfit();
      
     // Use AddPerformanceMetric to add myProfit to the strategy
     AddPerformanceMetric(myProfit);
   }
}
protected override void OnBarUpdate()
{
   // Print a string representing the Type of the performance metric at Index 0 of the PerformanceMetrics collection
   Print(PerformanceMetrics[0]);
}
```