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

Color defaults wont save

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

    Color defaults wont save

    Hi,

    I have coded an indicator that has definable colors for all lines and text drawn by indicator.

    Everything works fine expect the default colors always revert back to the set color where defined in variables. Even after saving the defaults.... The original parameters can be saved but the colors wont stay.

    I have trawled the internet looking for answers and found someone else with a simlar problem which was solved by removing the " XmlIgnore" however this just takes the colors away altogether in which case they need to be defined every time the indicator is run.

    The funny thing is that i got the below code from another program that someone else coded and it works fine and holds the values in that program... but not in mine... :-(

    Can anyone make any suggestions?





    [Description("Text Colour for last Alert2"), XmlIgnore, VisualizationOnly]
    [GridCategory("Status panel")]
    [NinjaTrader.Gui.Design.DisplayName("Levels Color")]
    public Color LevelNormal
    {
    get { return this.textbrushOff.Color; }
    set { this.textbrushOff = new SolidBrush(value); }
    }

    #2
    I think this is where the serializable comes in...




    Originally posted by marty087 View Post
    Hi,

    I have coded an indicator that has definable colors for all lines and text drawn by indicator.

    Everything works fine expect the default colors always revert back to the set color where defined in variables. Even after saving the defaults.... The original parameters can be saved but the colors wont stay.

    I have trawled the internet looking for answers and found someone else with a simlar problem which was solved by removing the " XmlIgnore" however this just takes the colors away altogether in which case they need to be defined every time the indicator is run.

    The funny thing is that i got the below code from another program that someone else coded and it works fine and holds the values in that program... but not in mine... :-(

    Can anyone make any suggestions?





    [Description("Text Colour for last Alert2"), XmlIgnore, VisualizationOnly]
    [GridCategory("Status panel")]
    [NinjaTrader.Gui.Design.DisplayName("Levels Color")]
    public Color LevelNormal
    {
    get { return this.textbrushOff.Color; }
    set { this.textbrushOff = new SolidBrush(value); }
    }

    Comment


      #3
      Originally posted by sledge View Post
      I think this is where the serializable comes in...
      As koganam said



      "Any inputs that are not serializable, if changed from the defaults, will not be saved with the indicator, unless you make your own arrangements to serialize such."

      search here

      Comment


        #4
        Thanks Sledge. Much appreciated.

        Here is the code i added... Works a charm.

        [Browsable(false)]
        public string LevelNormalColorSerialize
        {
        get { return SerializableColor.ToString(this.LevelNormal); }
        set { this.LevelNormal = SerializableColor.FromString(value); }
        }

        Comment


          #5
          Originally posted by marty087 View Post
          Thanks Sledge. Much appreciated.

          Here is the code i added... Works a charm.

          [Browsable(false)]
          public string LevelNormalColorSerialize
          {
          get { return SerializableColor.ToString(this.LevelNormal); }
          set { this.LevelNormal = SerializableColor.FromString(value); }
          }
          Have you remembered to dispose of your textBrushes ?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by GLFX005, Today, 03:23 AM
          0 responses
          1 view
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          11 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          6 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          14 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          3 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X