Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

      JesseNinjaTrader Customer Service

      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.
          JesseNinjaTrader Customer Service

          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);
              }
              JesseNinjaTrader Customer Service

              Comment


                #8
                Thank you Jesse, that answered my question!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Gmonte, 10-01-2022, 08:28 AM
                2 responses
                187 views
                0 likes
                Last Post charlesthomas  
                Started by ETFVoyageur, 05-18-2024, 12:45 AM
                5 responses
                31 views
                0 likes
                Last Post ETFVoyageur  
                Started by Kraken29, Today, 03:24 PM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by Skifree, Today, 11:47 AM
                5 responses
                19 views
                0 likes
                Last Post Skifree
                by Skifree
                 
                Started by ETFVoyageur, Today, 10:34 AM
                10 responses
                25 views
                0 likes
                Last Post ETFVoyageur  
                Working...
                X