Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DisplayName Override Issue

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

    DisplayName Override Issue

    There appears to be a bug when overriding DisplayName. I'm on the latest version of NinjaTrader, so not sure if this was occurring in prior versions.

    I am overriding DisplayName as outlined in the Help Guide. http://ninjatrader.com/support/helpG...isplayname.htm

    When the Label is blanked out in the Indicator Properties dialog, the Name of the indicator no longer shows in the Configured section of the dialog.

    I am using the following undocumented code to work around the issue:

    Code:
    public override string DisplayName
    {
      get
      {
        if (Name == string.Empty) return "My Custom Display " + DefaultName;
        else return "My Custom Display " + Name; ;
      }
    }
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    Hello TheTradingMantis,

    You generally need to use the State in this override to return a value in various different states. Does it work if you make sure to return the name when the state is SetDefaults or Configure?

    Code:
    public override string DisplayName
    {
        get {
            if (State == State.SetDefaults) return "StrategyName";
            else return "My Custom Display " + Name;
        } 
    }​

    Comment


      #3
      Hi Jesse,

      Using State == State.SetDefaults works and is a better approach than checking the Name. Thanks for the recommendation!

      Still need to use the undocumented DefautlName when returning a value in State.SetDefaults. Maybe the Help Guide can be updated to reflect this?

      Code:
      public override string DisplayName
      {
        get
        {
          if (State == State.SetDefaults) return DefautlName;
          else return "My Custom Display " + Name;
        }
      }​


      If you don't use DefautlName, or a hardcoded string in your example, this happens when Label is blanked out:

      Click image for larger version  Name:	Properties Example.png Views:	0 Size:	11.4 KB ID:	1234898
      Last edited by TheTradingMantis; 02-10-2023, 10:13 AM.
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment


        #4
        Hello TheTradingMantis,

        I will make the recommendation to include that in the help guide sample. Just for clarification the DisplayName override its self is documented and supported, just the part about using the State is not described there.

        Comment


          #5
          I have corrected my post above as I meant to use DefaultName, not DisplayName. Using DisplayName in the DisplayName override is recursive and will crash NinjaTrader.
          The Trading Mantis
          NinjaTrader Ecosystem Vendor - The Trading Mantis

          Comment


            #6
            Hello TheTradingMantis,

            Thanks for clarifying that, yes DefaultName is not documented. Generally you would just use the Name property in the DisplayName override and construct a custom result. I am not sure what specific use cases the DefaultName is used in so I couldn't really provide any insight on that property.

            Comment


              #7
              Name appears to be tied to the Label in the Indicator Properties dialog. If Label is blanked out, Name will then be blank. This can be verified by
              Code:
              ...
              else if (State == State.Configure)
              {
                Print(Name.ToString())
              }
              If one wants to avoid using the undocumented DefaultName, then a hardcoded string would need to be used as Jesse suggested in his sample code above.
              Code:
              public override string DisplayName
              {
                get
                {
                  if (State == State.SetDefaults) return "SomeIndicator";
                  else return "My Custom Display " + Name;
                }
              }​
              The Trading Mantis
              NinjaTrader Ecosystem Vendor - The Trading Mantis

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              571 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 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
              549 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              549 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X