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 yertle, Yesterday, 08:38 AM
              7 responses
              28 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by bmartz, 03-12-2024, 06:12 AM
              2 responses
              19 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by funk10101, Today, 12:02 AM
              0 responses
              3 views
              0 likes
              Last Post funk10101  
              Started by gravdigaz6, Yesterday, 11:40 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by MarianApalaghiei, Yesterday, 10:49 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X