Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set the legend in an indicator panel?

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

    How to set the legend in an indicator panel?

    How do I control the ID legend in my indicator's panel? In NT7 that was populated by the return from overriding ToString().

    That does not appear to be so in NT8. ToString() is called once, quite early, too early to be helpful in setting that legend. I cannot see anywhere that what ToString() returns is used. Certainly not in setting the indicator's panel legend. So:
    • How should I set the indicator panel's legend in NT8?
    • What is ToString() output used for?

    Conjecture: setting DisplayName property would do it -- the problem is that is read-only.

    Interesting note: Visual Studio seems to be using the value ToString() returns

    --EV
    Last edited by ETFVoyageur; 08-06-2015, 04:57 AM.

    #2
    Originally posted by ETFVoyageur View Post
    How do I control the ID legend in my indicator's panel? In NT7 that was populated by the return from overriding ToString().



    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      DisplayName is a virtual, you can override it if you code if you wish

      Code:
      public override string DisplayName
      {
          get { return "A Custom Display for " + Name; }
      }
      ToString is called to set the display name for the indicator dialogs configured list.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Originally posted by NinjaTrader_Matthew View Post
        DisplayName is a virtual, you can override it if you code if you wish
        I can indeed override it. I was interested to note that I cannot provide even a private Set() method for it, because the base version does not have one. Not a big deal ... the initialization code just directly writes the variable backing the property.

        ToString is called to set the display name for the indicator dialogs configured list.
        Not really. Before I did anything, it was set to DisplayName, not to the string I returned from ToString(). I still have not found anything that ToString() is used for, other than by Visual Studio

        =====
        OK -- I have it working now, but it is a touch more complicated than you might think. The issue is that the property must be set in State.SetDefaults to appear in the Indicators dialog, however a value I need (InstrumentName) is not available at that time. I did come up with a solution that works pretty well, though:
        • Override the property with an explicit read-only property
        • Have the Get() method return the base value until it is initialized. That is what will appear in the Indicators dialog.
        • Initialize the property in State.Configure -- the first time InstrumentName is available. This is what will show up in the chart panel.
        • ToString() has nothing to do with anything in this process. ToString() is called after returning from State.SetDefaults, but I have no idea what is done with the string it hands back.

        --EV
        Last edited by ETFVoyageur; 08-06-2015, 11:02 AM.

        Comment


          #5
          By the way, it strikes me that this is a non-obvious code breaker, and should be documented with the code breakers.

          --EV

          Comment


            #6
            It was never officially documented in the language reference, therefore does not qualify for the code breaking table. However it is documented with the Reference Samples, which the Code Breaking Implementation Changes Overview Miscellaneous section points to:



            We have an outstanding task to get the reference samples in the Help Guide to make changes like this more obvious or easier to search for.
            MatthewNinjaTrader Product Management

            Comment


              #7
              I'm surprised -- I did not realize that ToString() was not documented.

              One further refinement occurred to me, so I just checked on it. For those who implement GetProperties(), InstrumentName is set then so you could update DisplayName from there. Also undocumented / unsupported.

              EDIT: too bad, but this does not work. I'm taking a quick look at why, but its not worth a lot of time. Falling back on the stock version is not a big problem for the Indicator dialog, and thanks to Matthew we can handle the chart panel case just fine without this.

              --EV
              Last edited by ETFVoyageur; 08-06-2015, 03:30 PM.

              Comment


                #8
                This all just got a lot simpler, which makes me happier -- I always worry that if your solution is not simple, then you do not understand the problem well enough yet and your code is probably sub-optimal.

                The answer became plain after looking at my trace information. The thing that works best is to just override the property, as Matthew suggested, and then have DisplayName.Get() return ToString().

                Voila -- NT7-like behavior -- the Indicators dialog and the chart panel both use ToString(). Works like a champ. Limited testing so far, but I don't foresee further problems.

                Thanks to Matthew for getting me going with overriding DisplayName.

                --EV

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,604 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                8 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                4 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                13 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X