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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          131 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          74 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          117 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          111 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          89 views
          0 likes
          Last Post CarlTrading  
          Working...
          X