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

Unrealized PnL on Chart

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

    #16
    Hello Josh,

    I have tried - and can see the "Unrealized PNL" - but it shows total unrealized PNL for account.

    So if I have position on 2 instruments (on different charts) - it shows total unrealized PNL for both instruments combined.

    How can I see unrealized PNL per instrument using Indicator? (doesn't matter, per chart which will only have 1 instrument or per instrument regardless of chart).

    Thanks

    Comment


      #17
      I am looking into this with QA to see if this is possible and will report back here when I have more information.
      Josh G.NinjaTrader Customer Service

      Comment


        #18
        As an alternative idea - it is probably possible to run "Helper" strategy that will monitor account position... and will update static values in add-on - and an indicator could read these values...

        If it is possible - could you please provide a sample on how to accomplish it? And I also assume there will be no lagging since strategy and indicators will be synchronized based on bar close...

        Thanks

        Comment


          #19
          Hello,

          Any updates on this?

          Thanks

          Comment


            #20
            I am still looking at this. I'll post here when I have more information.
            Josh G.NinjaTrader Customer Service

            Comment


              #21
              While the AccountItemUpdate feed does not associate UPnL to instruments, the PositionUpdate feed does. As well, Strategies have their own internal Positions series. I am including a sample which demonstrates using each of these.


              Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.


              References :
              Position.GetUnrealizedProfitLoss
              Account.PositionUpdate
              Attached Files
              Jessica P.NinjaTrader Customer Service

              Comment


                #22
                If the indicators logic and event handlers were input into a strategy, the entire events to print the PnL were either chosen to occur through a user defined bool, what will the syntax under namespace "private Account myAccount" be in a strategy?
                When compile an error saying that "expected class, delegate, enum, interface, struct"

                Comment


                  #23
                  Hello LoganJKTrader,

                  If you want to access the Account that we apply the strategy to, you can simply use "Account"

                  I.E.

                  Print(Account.Name);



                  Subscribing to Account.PositionUpdate in a strategy would look like the following in State.DataLoaded

                  if (Account != null)
                  Account.PoisitionUpdate += MyAccountLevelOnPositionUpdateMethod;


                  Unsubscribing in State.Terminated would look like:

                  if (Account != null)
                  Account.PoisitionUpdate -= MyAccountLevelOnPositionUpdateMethod;

                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Aviram Y, Today, 05:29 AM
                  3 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  3 responses
                  26 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by bmartz, 03-12-2024, 06:12 AM
                  3 responses
                  30 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by gentlebenthebear, Today, 01:30 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by cls71, Today, 04:45 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X