PerformanceMetrics

View as Markdown

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

1// Define a new SampleCumProfit object
2NinjaTrader.NinjaScript.PerformanceMetrics.SampleCumProfit myProfit;
3protected override void OnStateChange()
4{
5 if (State == State.Configure)
6 {
7 // Instantiate myProfit to a new instance of SampleCumProfit
8 myProfit = new NinjaTrader.NinjaScript.PerformanceMetrics.SampleCumProfit();
9
10 // Use AddPerformanceMetric to add myProfit to the strategy
11 AddPerformanceMetric(myProfit);
12 }
13}
14protected override void OnBarUpdate()
15{
16 // Print a string representing the Type of the performance metric at Index 0 of the PerformanceMetrics collection
17 Print(PerformanceMetrics[0]);
18}