Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating Drawdown and Cumulative Drawdown per bar during a order execution

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Calculating Drawdown and Cumulative Drawdown per bar during a order execution

    Hi,

    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.

    Code:
    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.
    ​The question is how to calculate the CumDD per bar?

    Base on the CumDD of SystemPerformance, here is an example of one day:

    Click image for larger version  Name:	Screenshot 2023-08-04 at 16.39.28.png Views:	4 Size:	506.4 KB ID:	1263052

    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?

    Click image for larger version  Name:	Screenshot 2023-08-04 at 18.09.19.png Views:	1 Size:	1.20 MB ID:	1263075

    Here is a screen capture of the trade

    Click image for larger version  Name:	Screenshot 2023-08-04 at 16.38.23.png Views:	4 Size:	110.2 KB ID:	1263053

    Click image for larger version  Name:	Screenshot 2023-08-04 at 16.53.54.png Views:	4 Size:	529.1 KB ID:	1263055
    Last edited by Shai Samuel; 08-04-2023, 09:16 AM.

    #2
    Hello Shai Samuel,

    This thread will remain open for any community members that would like to assist with creating custom calculations.

    One thought may be that you track the total draw down on each bar close, then subtract the current bars draw down to the previous bars draw down, which would be the amount of change on that bar.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,

      It appears I had a typo in my data. After fixing it (edited the initial post Image of the step by step excel, the issue still exists, but smaller.

      I also added the excel I used to calculate the values.

      if I understand your suggestion correctly, nothing will offset the CumDD to the positive side, which is not the case.
      Last edited by Shai Samuel; 08-04-2023, 09:14 AM.

      Comment


        #4
        Dear Chelsea,

        Thinking further on your suggestion, the only solution I can see at the moment is to have the intra-trade Cum.MaxDD calculated as the negative values of the the Cum Profit, much like the DD itself. This doesn't look very accurate, but at least leads to the correct final value at the end of the trade. I have added the value in the green column.

        I would be happy for more reflation by the community.


        Click image for larger version

Name:	Screenshot 2023-08-04 at 18.49.22.png
Views:	260
Size:	970.0 KB
ID:	1263087​​
        Last edited by Shai Samuel; 08-04-2023, 09:52 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        44 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        65 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X