Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I compute Cumulative Net Profit in OnPositionUpdate() callback?

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

    How do I compute Cumulative Net Profit in OnPositionUpdate() callback?

    Hello,

    Can you please advise how I could compute Cumulative Net Profit (see attached diagram) in the OnPositionUpdate() callback? Thanks

    Billy

    #2
    Hello,

    To further clarify my question, I am trying to print out the cumulative net profit of the strategy I am currently running, what callback should I use, and how to access the value. Thanks!

    Billy

    Comment


      #3
      Hello billythekid72,

      You can see the following link for a sample of getting the cumulative profit from a strategy.

      Comment


        #4
        Thank you Jesse,

        If I have multiple strategies running currently and need to print the cumulative profit for the strategy (within each strategy), how can I achieve that? Thanks

        Billy

        Comment


          #5
          Hello billythekid72,

          Each strategy would need to print its own values. Strategies are not aware of what other strategies are doing so each strategy would need the code in it to use its own performance values.

          Comment


            #6
            Hello Jesse,

            So is my understanding correct that if I print SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit within the individual strategy, it would correctly get the cum profit for its own last trade? Thanks

            Billy

            Comment


              #7
              Hello billythekid72,

              That would be the cumulative profit for all trades that single strategy placed. Each strategy has individual performance values so when you use SystemPerformance.AllTrades that refers to just this strategies performance values.

              If you want only the most recent trade then you need to isolate just that trade. There is a sample of how to get the last trade along with its profit here: https://ninjatrader.com/support/help...collection.htm
              Code:
              if (SystemPerformance.AllTrades.Count > 1)
              {
                  Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];​
                  Print(lastTrade.ProfitCurrency);
              }

              Comment


                #8
                Thank you Jesse, that answered my question!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                63 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                139 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X