To be able to better analyze my strategies, I am working on a PNL, which calculate the Profit, CumProfit, DD, CumDD per bar during the trade processing. Profit, CumProfit, DD are easy to calculate. My issue is with calculating CumDD, where I find difference with the result getting from SystemPerformance.
My base price is the enter order, which I submit, and I am using SystemPerformance.AllTrades.FirstOrDefault to get the Exit order, and final trade performance data.
trade = owner.SystemPerformance.AllTrades.FirstOrDefault(t=> t.Entry.Order==entryOrder && t.Exit.Order!=null);
- CumProfit is easy to calculate base on the Close[0]-Entry.Order.AverageFillPrice.
- Profit is the difference between the last CumProfit and the current.
- DD is just the negative Profit values.
Base on the CumDD of SystemPerformance, here is an example of one day:
The Profit is simply the difference between the Enter and Exit price multiple by $50 (ES). The MaxDD is only the Negative Profits, and the CumProfit is calculated as previous Min(CumProfit+Profits,0) (only the negative values.
When extracting the same logic to one trade, bar by bar I get way different result. The CumProfit of the bar-by-bar trade is the same as the profit of the trade ($-250). but the total Cum. MaxDD is totally different. Any ideas?
Here is a screen capture of the trade

Comment