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 fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X