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 CaptainJack, 05-29-2026, 05:09 AM
              0 responses
              220 views
              0 likes
              Last Post CaptainJack  
              Started by CaptainJack, 05-29-2026, 12:02 AM
              0 responses
              135 views
              0 likes
              Last Post CaptainJack  
              Started by charlesugo_1, 05-26-2026, 05:03 PM
              0 responses
              150 views
              0 likes
              Last Post charlesugo_1  
              Started by DannyP96, 05-18-2026, 02:38 PM
              1 response
              235 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 05-11-2026, 05:56 AM
              0 responses
              193 views
              0 likes
              Last Post CarlTrading  
              Working...
              X