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, 05-11-2026, 05:56 AM
      0 responses
      52 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      29 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      194 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      355 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      274 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X