示例#1
0
        // This is called as the values of a trade metric are saved, which occurs e.g. in the strategy analyzer on optimizer runs
        protected override void OnCopyTo(PerformanceMetricBase target)
        {
            // You need to cast, in order to access the right type
            SampleCumProfit targetMetrics = (target as SampleCumProfit);

            if (targetMetrics != null)
            {
                Array.Copy(Values, targetMetrics.Values, Values.Length);
            }
        }
示例#2
0
        // This is called as the trade metric is merged, which occurs e.g. in the strategy analyzer for the total row and for aggregate
        protected override void OnMergePerformanceMetric(PerformanceMetricBase target)
        {
            // You need to cast, in order to access the right type
            SampleCumProfit targetMetrics = (target as SampleCumProfit);

            // This is just a simple weighted average sample
            if (targetMetrics != null && TradesPerformance.TradesCount + targetMetrics.TradesPerformance.TradesCount > 0)
            {
                for (int i = 0; i < Values.Length; i++)
                {
                    targetMetrics.Values[i] = (targetMetrics.Values[i] * targetMetrics.TradesPerformance.TradesCount + Values[i] * TradesPerformance.TradesCount) / (TradesPerformance.TradesCount + targetMetrics.TradesPerformance.TradesCount);
                }
            }
        }