[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:
Compiles fine but the default colors are not being picked up, so clearly I'm missing something here. Again, this is not a plot color but one used by line draw events. If you look at the indicator it hopefully makes sense.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
-
Yeah, you nailed it - sorry again for bothering you with something so trivial. I guess I'm just not used to defining my properties 4.x style. Thanks again.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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
672 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
577 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment