17 using System.Collections.Generic;
18 using Newtonsoft.Json;
278 var maxConsecutiveWinners = 0;
279 var maxConsecutiveLosers = 0;
280 var maxTotalProfitLoss = 0m;
281 var maxTotalProfitLossWithMfe = 0m;
282 var sumForVariance = 0m;
283 var sumForDownsideVariance = 0m;
284 var lastPeakTime = DateTime.MinValue;
285 var isInDrawdown =
false;
286 var allTradeDurationsTicks =
new List<long>();
287 var winningTradeDurationsTicks =
new List<long>();
288 var losingTradeDurationsTicks =
new List<long>();
289 var numberOfITMOptionsWinningTrades = 0;
291 foreach (var trade
in trades)
293 if (lastPeakTime == DateTime.MinValue) lastPeakTime = trade.EntryTime;
309 if (trade.ProfitLoss > 0)
320 winningTradeDurationsTicks.Add(trade.Duration.Ticks);
325 maxConsecutiveWinners++;
326 maxConsecutiveLosers = 0;
338 lastPeakTime = trade.ExitTime;
339 isInDrawdown =
false;
352 sumForDownsideVariance += (trade.ProfitLoss - prevAverageLoss) * (trade.ProfitLoss -
AverageLoss);
358 losingTradeDurationsTicks.Add(trade.Duration.Ticks);
367 numberOfITMOptionsWinningTrades++;
368 maxConsecutiveLosers = 0;
369 maxConsecutiveWinners++;
375 maxConsecutiveWinners = 0;
376 maxConsecutiveLosers++;
390 sumForVariance += (trade.ProfitLoss - prevAverageProfitLoss) * (trade.ProfitLoss -
AverageProfitLoss);
395 allTradeDurationsTicks.Add(trade.Duration.Ticks);
427 if (allTradeDurationsTicks.Count > 0)
429 if (winningTradeDurationsTicks.Count > 0)
431 if (losingTradeDurationsTicks.Count > 0)