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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          66 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X