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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            63 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            139 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X