[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 | ||
---|---|---|---|---|
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
10 responses
1,767 views
0 likes
|
Last Post
by Leafcutter
Today, 03:01 AM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, 04-23-2024, 07:51 PM
|
2 responses
30 views
0 likes
|
Last Post
by Max238
Today, 02:25 AM
|
||
Started by Shansen, 08-30-2019, 10:18 PM
|
24 responses
943 views
0 likes
|
Last Post
by spwizard
Today, 01:29 AM
|
||
Started by Max238, Today, 01:28 AM
|
0 responses
9 views
0 likes
|
Last Post
by Max238
Today, 01:28 AM
|
||
Started by rocketman7, Today, 01:00 AM
|
0 responses
7 views
0 likes
|
Last Post
by rocketman7
Today, 01:00 AM
|
Comment