Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,281 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      19 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by Tim-c, Today, 02:10 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X