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 Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              557 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X