Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cant overwrite default properties when saving indicator template

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

    Cant overwrite default properties when saving indicator template

    I have an indicator with a property defining text color that gets drawn onto the chart. However whenever I change the color in the UI and click "Save as default"(or any named template) it just defaults to black. How can I get it to actually save and overwrite the defaults for a user?
    Code:
    // In state.setdefaults
    TextColor = Brushes.Black;
    
    // In properties
      [NinjaScriptProperty]
      [XmlIgnore]
      [Display(Name = "Text Color", Description = "Color of text", Order = 2, GroupName = "Text")]
       public Brush TextColor
        { get; set; }​

    #2
    Hello sakura1337,

    Thank you for your post.

    In properties, have you included a code snippet to serialize the brush? Serialization is necessary for NinjaTrader to use the brush input throughout the program.

    [Browsable(false)]
    public string TextColorSerialize
    {
    get { return Serialize.BrushToString(TextColor); }
    set { TextColor = Serialize.StringToBrush(value); }
    }

    Please also check out this Help Guide page on User Definable Color Inputs, which includes an example SampleBrushInput you can use as a reference. ​​
    Last edited by NinjaTrader_Gaby; 08-10-2023, 07:18 AM.

    Comment


      #3
      Thanks Gaby! Exactly what I needed.

      Comment


        #4
        NinjaTrader_Gaby

        How would we approach this concept for text font options?
        Code:
                [NinjaScriptProperty]
                [XmlIgnore]
                [Display(Name = "Font, size, type, style",
                    Description = "Select font, style, size to display on chart",
                    GroupName = "Text",
                    Order = 1)]
                public Gui.Tools.SimpleFont TextFont
                { get; set; }​

        Comment


          #5
          Since you are using the SimpleFont class, NinjaTrader will serialize these automatically.

          Code:
          public NinjaTrader.Gui.Tools.SimpleFont TextFont
          { get; set; }
          if (State == State.SetDefaults)
          {
          TextFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 14);
          }

          Comment


            #6
            Originally posted by NinjaTrader_Gaby View Post
            Since you are using the SimpleFont class, NinjaTrader will serialize these automatically.

            Code:
            public NinjaTrader.Gui.Tools.SimpleFont TextFont
            { get; set; }
            if (State == State.SetDefaults)
            {
            TextFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 14);
            }
            It seems when I save to template the font changes are not accounted for? I have tried reloading NT and re-compiling the script.

            Code:
            if (State == State.SetDefaults)
            {
            TextFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 14);
            }
            
            //props
                    [NinjaScriptProperty]
                    [XmlIgnore]
                    [Display(Name = "Font, size, type, style", Description = "Select font, style, size to display on chart", GroupName = "Text", Order = 1)]
                    public NinjaTrader.Gui.Tools.SimpleFont TextFont
                    { get; set; }​

            Comment


              #7
              Hello sakura1337,

              Remove the XmlIgnore attribute.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              156 views
              1 like
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              90 views
              1 like
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              138 views
              2 likes
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              130 views
              1 like
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              107 views
              0 likes
              Last Post CarlTrading  
              Working...
              X