Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CONDITIONAL Override of DisplayName

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

    CONDITIONAL Override of DisplayName

    Hi,
    To override DisplayName of a strategy in NinjaScript is easy. To override DisplayName based on specific condition is also easy.
    However, I struggle to display the default DisplayName if the specific condition is not true.
    I can still display a the default Name see (1), but not the default DisplayName, see (2-3).

    (1) This here works:
    public override string DisplayName
    {
    get
    {
    if (myCondition)
    {return "myName";}
    else {return (Name);}
    }
    }

    (2) This here can't work:
    public override string DisplayName
    {
    get
    {
    if (myCondition)
    {return "myName";}
    else {return (DisplayName);} // default DisplayName was overridden before !!!
    }
    }

    (3) This here doesn't work either:
    stringDisplayName = (DisplayName); // This in itself works. Can print it.
    public override string DisplayName
    {
    get
    {
    if (myCondition)
    {return "myName";} // fine
    else {return (stringDisplayName);} // Here is the issue, the string Variable is filled, but doesn't get displayed on the chart.
    }
    }

    Any idea how to display the stringDisplayName with default DisplayName properties when the condition is not true?
    Or how to otherwise access and display the default DisplayName, consisting of the Name of the Strategy and settings of all input parameters?
    Thanks for letting me know.
    NT-Roland


    #2
    Hi Roland,

    this could work, but I haven't tested it.

    Code:
    public override string DisplayName
    {
        get
        {
            if (myCondition) {return "myName";}
            else {return (base.DisplayName);} // default DisplayName was overridden before !!!
        }
    }

    Comment


      #3
      Hi MojoJojo,
      It does. Thank you.
      NT-Roland

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X