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

Get cumulative profit and loss of current session

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

    Get cumulative profit and loss of current session

    Hello,

    How can I get the total profit and loss per session? Ideally this would reset each trading day and update OnBarUpdate and would also include the Unrealised profit and loss Can you provide a little example of how to do it ?

    Thanks for your help

    #2
    Hi roblogic,

    Thanks for your post.

    You can use the SystemPerformance class to get strategy performance data. See this reference sample that demonstrates how to reset values at the beginning of a new trading session.

    Please let me know if you have any questions.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response. What I want to check OnBarUpdate is the Total PnL as it is displayed in the accounts tab.

      This resets each trading day, automatically as session close, updates OnBarUpdate and has both the realised and unrealised PnL. Maybe the title of the thread is a bit misleading but this is what I need. Please can you be specific on how to track this Total PnL?

      Comment


        #4
        Hi roblogic, thanks for the follow-up.

        Taking the session PnL for the real account would require more code to be written in your script. You would need to use the Account object that your strategy has and get all the executions that occurred on the account for the session, then calculate the PnL for all of the executions.

        Please let me know if you have any further questions on this material.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Ok thanks for the clarification. And if I want to track the evolution of the cumulative PnL only on historical data I assume the account class won't work. Correct? Then what would you suggest?

          Comment


            #6
            Hi roblogic, thanks for your reply.

            No, using the Account object would not work in historical backtest. You would need to use the SystemPerformance class to track historical values from the strategy.

            Kind regards.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mestor, 03-10-2023, 01:50 AM
            16 responses
            388 views
            0 likes
            Last Post z.franck  
            Started by rtwave, 04-12-2024, 09:30 AM
            4 responses
            31 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Started by yertle, Yesterday, 08:38 AM
            7 responses
            29 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            22 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            7 views
            0 likes
            Last Post funk10101  
            Working...
            X