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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X