Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

brushes are not saving

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

    brushes are not saving

    8071, I use a custom indicator on one chart with 3 time frames. In public properties I change color and placement on chart for each time frame. After I do this I save these settings and everything is fine for the session. But when I close and open the next day, the colors on all time frames revert to the default color, forcing me to set the 2 that changed again. The placement on chart setting is fine.

    Do you know why this is occurring?

    Thank you.

    #2
    Originally posted by imalil View Post
    8071, I use a custom indicator on one chart with 3 time frames. In public properties I change color and placement on chart for each time frame. After I do this I save these settings and everything is fine for the session. But when I close and open the next day, the colors on all time frames revert to the default color, forcing me to set the 2 that changed again. The placement on chart setting is fine.

    Do you know why this is occurring?

    Thank you.

    Are you serializing the colors vars? See below

    Comment


      #3
      Hello imalil,

      Thanks for your post.

      As member marty087 has asked/advised are the colors being serialized?

      If so and if the issue remains, please post the source code file or alternatively send it into PlatformSupport[at]NinjaTrader[dot]Com, mark the e-mail subject Atten: Paul and please add a link to this thread for reference.

      Comment


        #4
        I tried it, but I don't think I'm doing it right.

        Here's my variable:
        private Brush chosenColor = Brushes.Cyan;
        Here's my property:
        [XmlIgnore()]
        [NinjaScriptProperty]
        [Display(Description = "Color of results", GroupName = "Display", Order = 1)]
        public Brush ChosenColor
        {
        get { return chosenColor; }
        set { chosenColor = value; }
        }
        What do I need to change to make this work?
        Thank you.

        Comment


          #5
          Hello imalil,

          Thanks for your reply.

          With reference to the link provided by member marty087, a complete property for brushes that includes serialization would be:

          Code:
          [XmlIgnore()]
          [Display(Name = "BorderBrush", GroupName = "NinjaScriptParameters", Order = 0)]
          public Brush BorderBrush
          { get; set; }
          
          [Browsable(false)]
          public string BorderBrushSerialize
          {
          	get { return Serialize.BrushToString(BorderBrush); }
             	set { BorderBrush = Serialize.StringToBrush(value); }
          }
          In your case then:

          Code:
          [XmlIgnore()]
          [NinjaScriptProperty]	
          [Display(Description = "Color of results", GroupName = "Display", Order = 1)]
          public Brush ChosenColor
          {
          get { return chosenColor; }
          set { chosenColor = value; }
          }
          
          [Browsable(false)]
          public string ChosenColorSerialize
          {
          	get { return Serialize.BrushToString(chosenColor); }
             	set { chosenColor = Serialize.StringToBrush(value); }
          }
          Not to add confusion but to explain, in NT8 you do not need to declare private variables linked to public properties. This is why the example shows a simple { get; set; } and is why in the serialization you only see the capitalized name of BorderBrush. You would need to declare the default setting of the color in State.SetDefaults like: ChosenColor = Brushes.Red; Then in the OnBarUpdate() section, you would use the public name ChosenColor instead of the private chosenColor. All this will save coding time and keep the code cleaner for you, however, you can also be successful using the NT7 manner with the private and public variables. To see the NT8 way of doing things, take a look at the indicator MaCrossBuilder http://ninjatrader.com/support/forum...d=7&linkid=906

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          331 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
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          550 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X