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 alifarahani, Today, 09:40 AM
              2 responses
              12 views
              0 likes
              Last Post alifarahani  
              Started by junkone, Today, 11:37 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by pickmyonlineclass, Today, 12:23 PM
              0 responses
              1 view
              0 likes
              Last Post pickmyonlineclass  
              Started by frankthearm, Yesterday, 09:08 AM
              12 responses
              44 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by quantismo, 04-17-2024, 05:13 PM
              5 responses
              35 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X