Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position Display Indicator

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

    Position Display Indicator

    Hi there,

    I'm trying to get the Realized PnL in the Position Display Indicator to show Ticks. It currently shows currency in USD.

    I've found the Line for The value. It's as follows:

    realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar)

    I've tried changing "Currency.UsDollar" to "Ticks". When I do this I get the following error:
    Code SC0103
    The name 'Tics' does not exist in the current context.

    Any ideas on how to show Realized PnL in Ticks?

    #2
    try this:
    Code:
    double pnl = Account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
    double points = pnl / Instrument.MasterInstrument.PointValue;
    int ticks = Convert.ToInt32(points / TickSize);​

    Comment


      #3
      I had a lot of error with the spaces in the second and third line so I took the spaces out. These are the errors that come up now:
      Click image for larger version

Name:	image.png
Views:	157
Size:	33.9 KB
ID:	1327969​​
      Attached Files

      Comment


        #4
        Hello sissom,

        Occasionally a non-alpha-numeric character can be copied from the forum.

        Try deleting the copied and pasted lines first, then type the code by hand.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chelsea and CLS,
          That helped those. I think I'm getting closer, but still not quite there.

          This what I have currently

          Code:
          realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
          double realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
          double Points = realizedPnL / Instrument.MasterInstrument.PointValue;
          int Ticks = Convert.ToInt32(Points / TickSize);

          I get this error:
          CS0844
          ​Cannot use local variable 'realizedPnL' before it is declared. The declaration of the local variable hides the field 'PositionDisplayIndicator.realzedPnL'.

          Comment


            #6
            Hello sissom,

            You have:

            realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);
            double realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);​

            The first line attempts to use a variable before it's declared. (The type double before the variable name is how it is declared)
            The second line declares the realizedPnL.
            The first line appears to be a duplicate anyway and can be deleted.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks again Chelsea,

              Deleting the first line took the error away, but the Realized PnL still shows currency, and I'm looking for ticks.
              So frustrating...

              Comment


                #8
                Hello sissom,

                Are you printing the Ticks variable?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Probably not because I don't know what that means

                  Comment


                    #10
                    Hello sissom,

                    Below is a link to the support article on adding debugging prints to understand behavior and includes videos.


                    After the calculations the Ticks variable should be holding the number of ticks of profit or loss.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks so much Chelsea. I really appreciate the information. I have my homework

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      557 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      324 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      101 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      545 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      547 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X