Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Paul H.NinjaTrader Customer Service

    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.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by trilliantrader, 04-18-2024, 08:16 AM
          4 responses
          18 views
          0 likes
          Last Post trilliantrader  
          Started by mgco4you, Today, 09:46 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by wzgy0920, Today, 09:53 PM
          0 responses
          9 views
          0 likes
          Last Post wzgy0920  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          10 views
          0 likes
          Last Post Rapine Heihei  
          Working...
          X