Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to display PnL from Positions tab on chart

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

    How to display PnL from Positions tab on chart

    I tried doing the following:

    double uPnL = (double)Position.GetUnrealizedProfitLoss(Performan ceUnit.Currency, Close[0]);
    Draw.TextFixed(this, "UPnL", String.Format("Unrealized PnL: {0}", uPnL), TextPosition.BottomRight, Brushes.White, boldFont, Brushes.White, Brushes.Black, 85);

    While this does display the text on the chart, it always shows a 0, even when I have an open position. Any help is appreciated.

    #2
    Hello learningnt,

    Thanks for your post.

    Your code is for NT8 and you have posted in NT7 strategy development.

    I applied your code, in NT8, to real-time data and it displays the unrealized PNl of the position.
    If you are using the Calculate.OnBarClose mode then the text is only updated at the end of the bar.


    Last edited by NinjaTrader_PaulH; 04-09-2019, 06:40 AM. Reason: Added note about NT version

    Comment


      #3
      Does that include only trades done by the strategy, or all trades against that chart?

      Comment


        #4
        Also, is there any way to move this post to the NT8 section where it is more appropriate?

        Comment


          #5
          Hello learningnt,

          Thanks for your replies.

          The value of unrealizedPNL would only be for trades that have not closed that are initiated by the strategy.

          We will move this thread to NT8 strategy.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          561 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          325 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X