OnMergePerformanceMetric()

View as Markdown

Definition

This method is called when the Performance Metric would be aggregated and merged together (E.g. on the Strategy Analyzer’s total row).

Syntax

protected override void OnMergePerformanceMetric(PerformanceMetricBase merge)

Examples

1protected override void OnMergePerformanceMetric(PerformanceMetricBase target)
2{
3 // You need to cast, in order to access the right type
4 SampleCumProfit targetMetrics = (target as SampleCumProfit);
5
6 // This is just a simple weighted average sample
7 if (targetMetrics != null && TradesPerformance.TradesCount + targetMetrics.TradesPerformance.TradesCount > 0)
8 for (int i = 0; i < Values.Length; i++)
9 targetMetrics.Values[i] = (targetMetrics.Values[i] *targetMetrics.TradesPerformance.TradesCount + Values[i]* TradesPerformance.TradesCount) / (TradesPerformance.TradesCount + targetMetrics.TradesPerformance.TradesCount);
10}