Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parameter Persistence/Serialization in NT8

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

    Parameter Persistence/Serialization in NT8

    Hey guys - here's a section of one of my NT7 indicator's parameters settings:

    Code:
    [Description("Nlbl Color.")]
    		[GridCategory("Visual")]
    		[Gui.Design.DisplayNameAttribute("Nlbl Color")]
    		public Color NlblColor
    		{
    			get { return nlblColor; }
    			set { nlblColor = value; }
    		}
    		
    		// colors are not serialised by default, you are on your own
    		// serialisation is important when you try to save current color with the workspace
    		[Browsable(false)]
    		public string NlblColorSerialize
    		{
    			get { return Gui.Design.SerializableColor.ToString(nlblColor); }
    			set { nlblColor = Gui.Design.SerializableColor.FromString(value); }
    		}
    What I'm doing here is to allow the color to be serialized. I know this is more of a .Net 4 question but how do I do the same now in NT8?

    Code:
    [Range(3, int.MaxValue)]
    		[NinjaScriptProperty]
    		[Display(Name="NlblColor", Order=1, GroupName="Parameters")]
    		public Color NlblColor
    		{ get; set; }
    
    ???
    Thanks in advance.

    #2
    Originally posted by molecool View Post
    Hey guys - here's a section of one of my NT7 indicator's parameters settings:

    Code:
    [Description("Nlbl Color.")]
    		[GridCategory("Visual")]
    		[Gui.Design.DisplayNameAttribute("Nlbl Color")]
    		public Color NlblColor
    		{
    			get { return nlblColor; }
    			set { nlblColor = value; }
    		}
    		
    		// colors are not serialised by default, you are on your own
    		// serialisation is important when you try to save current color with the workspace
    		[Browsable(false)]
    		public string NlblColorSerialize
    		{
    			get { return Gui.Design.SerializableColor.ToString(nlblColor); }
    			set { nlblColor = Gui.Design.SerializableColor.FromString(value); }
    		}
    What I'm doing here is to allow the color to be serialized. I know this is more of a .Net 4 question but how do I do the same now in NT8?

    Code:
    [Range(3, int.MaxValue)]
    		[NinjaScriptProperty]
    		[Display(Name="NlblColor", Order=1, GroupName="Parameters")]
    		public Color NlblColor
    		{ get; set; }
    
    ???
    Thanks in advance.
    Should be the same. I cannot see why it would not be.

    Comment


      #3
      Originally posted by molecool View Post
      Hey guys - here's a section of one of my NT7 indicator's parameters settings:

      Code:
      [Description("Nlbl Color.")]
      		[GridCategory("Visual")]
      		[Gui.Design.DisplayNameAttribute("Nlbl Color")]
      		public Color NlblColor
      		{
      			get { return nlblColor; }
      			set { nlblColor = value; }
      		}
      		
      		// colors are not serialised by default, you are on your own
      		// serialisation is important when you try to save current color with the workspace
      		[Browsable(false)]
      		public string NlblColorSerialize
      		{
      			get { return Gui.Design.SerializableColor.ToString(nlblColor); }
      			set { nlblColor = Gui.Design.SerializableColor.FromString(value); }
      		}
      What I'm doing here is to allow the color to be serialized. I know this is more of a .Net 4 question but how do I do the same now in NT8?

      Code:
      [Range(3, int.MaxValue)]
      		[NinjaScriptProperty]
      		[Display(Name="NlblColor", Order=1, GroupName="Parameters")]
      		public Color NlblColor
      		{ get; set; }
      
      ???
      Thanks in advance.
      First off you want to use Brush for your color in the script. Color class is not valid in NT8

      Second here is an example -
      Code:
      [Browsable(false)]
      public string RatioBrushSerialize
      {
      	get { return Serialize.Brush2String(RatioBrush); }
      	set { RatioBrush = Serialize.String2Brush(value); }
      }
      Also, don't forget to use the XmlIgnore() attribute to your public property

      Comment


        #4
        Originally posted by Calonious View Post
        First off you want to use Brush for your color in the script. Color class is not valid in NT8

        Second here is an example -
        Code:
        [Browsable(false)]
        public string RatioBrushSerialize
        {
        	get { return Serialize.Brush2String(RatioBrush); }
        	set { RatioBrush = Serialize.String2Brush(value); }
        }
        Also, don't forget to use the XmlIgnore() attribute to your public property
        Thanks mate - do you happen to have a full example?

        Comment


          #5
          Take a look at the properties section of VolumeProfile.

          There are a couple of other indicators that have this as well.
          Code:
          		[XmlIgnore]
          		[Display(ResourceType = typeof(Custom.Resource), Name = "LineColor", Order = 2, GroupName = "NinjaScriptParameters")]
          		public Brush LineBrush { get; set; }
          
          		[Browsable(false)]
          		public string LineBrushSerialize
          		{
          			get { return Serialize.Brush2String(LineBrush); }
          			set { LineBrush = Serialize.String2Brush(value); }
          		}

          Comment


            #6
            We will be expanding documentation in this area shortly to assist with these new property attributes.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by Calonious View Post
              Take a look at the properties section of VolumeProfile.

              There are a couple of other indicators that have this as well.
              Code:
              		[XmlIgnore]
              		[Display(ResourceType = typeof(Custom.Resource), Name = "LineColor", Order = 2, GroupName = "NinjaScriptParameters")]
              		public Brush LineBrush { get; set; }
              
              		[Browsable(false)]
              		public string LineBrushSerialize
              		{
              			get { return Serialize.Brush2String(LineBrush); }
              			set { LineBrush = Serialize.String2Brush(value); }
              		}
              Brush is the WPF for Winforms Color so substitute it etc NT7 did this similar pattern for color also etc
              MicroTrends
              NinjaTrader Ecosystem Vendor - micro-trends.co.uk

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by lju45, Today, 04:54 AM
              0 responses
              5 views
              0 likes
              Last Post lju45
              by lju45
               
              Started by SuneSorgenfrei, Today, 04:47 AM
              0 responses
              6 views
              0 likes
              Last Post SuneSorgenfrei  
              Started by lakman184, Today, 03:09 AM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by romintrio, Today, 02:16 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by SCC74, Today, 01:32 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Jason  
              Working...
              X