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

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.
      Paul H.NinjaTrader Customer Service

      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
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,602 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          12 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X