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 CarlTrading, 03-31-2026, 09:41 PM
                1 response
                79 views
                1 like
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 04-01-2026, 02:41 AM
                0 responses
                40 views
                0 likes
                Last Post CarlTrading  
                Started by CaptainJack, 03-31-2026, 11:44 PM
                0 responses
                63 views
                2 likes
                Last Post CaptainJack  
                Started by CarlTrading, 03-30-2026, 11:51 AM
                0 responses
                63 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 03-30-2026, 11:48 AM
                0 responses
                54 views
                0 likes
                Last Post CarlTrading  
                Working...
                X