[NinjaScriptProperty] protected override void OnStateChange() { // properties and indicator settings go here if (State == State.SetDefaults) { ...... BarCount = 3; ExpireNL = 5; Brush NlblColor = Brushes.Lime; Brush NlslColor = Brushes.DarkOrange; Brush OldNlblColor = Brushes.Teal; Brush OldNlslColor = Brushes.Red; } // custom resources go here - i.e. indicators, custom data series, bars objects, etc. else if (State == State.Configure) { } } [Display(ResourceType = typeof(Custom.Resource), Name = "NlblColor", Order = 4, GroupName = "NinjaScriptParameters")] public Brush NlblBrush { get; set; } [Browsable(false)] public string NlblBrushSerialize { get { return Serialize.Brush2String(NlblBrush); } set { NlblBrush = Serialize.String2Brush(value); } } /// repeated below for the other colors
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Default brush attributes not being picked up as indicator parameters
Collapse
X
-
Default brush attributes not being picked up as indicator parameters
So I am porting one of my indicators I call NetLines - below a screengrab from NT7. The Net-Line colors can be set in the indicator settings so in NT8 I'm doing this right now:
Code:Tags: None
-
You have a local Brush declared OnStateChange() scope called NlblColor, however your public property refers to another public NlblBrush. These are different objects and your public brush has nothing assigned. Just make sure to match up the public brush in OnStateChange and it should work as you're expecting.
Also make sure you have added the XMLIgnore attribute to the public brush
Code:protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "MoleCoolor"; NlblBrush = Brushes.Lime; } else if (State == State.Configure) { } } [XmlIgnore] // make sure to ignore generating xml document field for this property [Display(ResourceType = typeof(Custom.Resource), Name = "NlblColor", Order = 4, GroupName = "NinjaScriptParameters")] public Brush NlblBrush { get; set; } [Browsable(false)] public string NlblBrushSerialize { get { return Serialize.Brush2String(NlblBrush); } set { NlblBrush = Serialize.String2Brush(value); } }
MatthewNinjaTrader Product Management
-
Not working... strange...
Originally posted by NinjaTrader_Matthew View PostYou have a local Brush declared OnStateChange() scope called NlblColor, however your public property refers to another public NlblBrush. These are different objects and your public brush has nothing assigned. Just make sure to match up the public brush in OnStateChange and it should work as you're expecting.
Also make sure you have added the XMLIgnore attribute to the public brush
Code:protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "MoleCoolor"; NlblBrush = Brushes.Lime; } else if (State == State.Configure) { } } [XmlIgnore] // make sure to ignore generating xml document field for this property [Display(ResourceType = typeof(Custom.Resource), Name = "NlblColor", Order = 4, GroupName = "NinjaScriptParameters")] public Brush NlblBrush { get; set; } [Browsable(false)] public string NlblBrushSerialize { get { return Serialize.Brush2String(NlblBrush); } set { NlblBrush = Serialize.String2Brush(value); } }
Well, that's embarrassing!
BTW, why do I need those [XmlIgnore] attributes? I do want those colors to show and be selectable/changeable in the indicator's parameters.
Anyway, I made the change and would love to tell you that it's now working but it's not :-(
I'll email you the stub code - perhaps you can pull it up and try it.
Comment
-
I responded to your code, let me know if that doesn't help or you have questions.
XmlIgnore-> the brush object itself cannot be saved to the xml (workspace) file. So you add that attribute which tells the XmlSerializer routine to skip that field.
This is also why you have to add that string brush object-> that string is what is actually being saved to the workspace xml file and allows you to restore any user defined colors which might deviate from the default value.MatthewNinjaTrader Product Management
Comment
-
Originally posted by NinjaTrader_Matthew View PostI responded to your code, let me know if that doesn't help or you have questions.
XmlIgnore-> the brush object itself cannot be saved to the xml (workspace) file. So you add that attribute which tells the XmlSerializer routine to skip that field.
This is also why you have to add that string brush object-> that string is what is actually being saved to the workspace xml file and allows you to restore any user defined colors which might deviate from the default value.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Belfortbucks, Today, 09:29 PM
|
0 responses
6 views
0 likes
|
Last Post
by Belfortbucks
Today, 09:29 PM
|
||
Started by zstheorist, Today, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Today, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
6 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
Comment