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 TraderBCL, Today, 04:38 AM
            2 responses
            17 views
            0 likes
            Last Post TraderBCL  
            Started by martin70, 03-24-2023, 04:58 AM
            14 responses
            106 views
            0 likes
            Last Post martin70  
            Started by Radano, 06-10-2021, 01:40 AM
            19 responses
            609 views
            0 likes
            Last Post Radano
            by Radano
             
            Started by KenneGaray, Today, 03:48 AM
            0 responses
            5 views
            0 likes
            Last Post KenneGaray  
            Started by thanajo, 05-04-2021, 02:11 AM
            4 responses
            471 views
            0 likes
            Last Post tradingnasdaqprueba  
            Working...
            X