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

# AddPerformanceMetric()

## Definition

Adds an instance of custom **Performance Metric** to a strategy used in strategy calculations.

## Method Return Value

This method does not return a value.

## Syntax

`AddPerformanceMetric(PerformanceMetricBase performanceMetric)`

This method should ONLY be called from the `OnStateChange()` method during State.Configure

## Parameters

| Parameter         | Description                               |
| ----------------- | ----------------------------------------- |
| performanceMetric | The performance metric object to be added |

## Examples

```csharp
protected override void OnStateChange()
{
     if (State == State.Configure)
     {
         AddPerformanceMetric(new NinjaTrader.NinjaScript.PerformanceMetrics.SampleCumProfit());
     }
}
```