• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 XimoTrader, Today, 12:57 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by FxInception, Today, 12:27 PM
            2 responses
            8 views
            0 likes
            Last Post FxInception  
            Started by siroya, Today, 10:34 AM
            1 response
            20 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by Leeroy_Jenkins, Today, 11:22 AM
            2 responses
            12 views
            0 likes
            Last Post Leeroy_Jenkins  
            Started by RedDuke, Today, 10:27 AM
            2 responses
            15 views
            0 likes
            Last Post RedDuke
            by RedDuke
             
            Working...
            X