Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Instrument drop down list
Collapse
X
-
Hello ballboy11,
You can use the following syntax to create an Instrument property:
Please let me know if I may be of further assistance.Code:protected override void OnStateChange() { if (State == State.SetDefaults) { InstrumentInput = Instrument.GetInstrument("ES 12-18"); } } [TypeConverter(typeof(NinjaTrader.Gui.Tools.InstrumentSelector))] [Display(Name="Select Instrument", GroupName = "Parameters", Order = 0)] public Instrument InstrumentInput { get; set; }
-
Thank you. Last question is there a way to for example on the set default section to have the current Instrument loaded. I see your example ES 12- 18 is hard coded. Can one have in your example Have ES update automatically so after rollover it will be ES 03-19 etc.
Comment
-
Hello ballboy11,
I don't believe there would be a suggested way to do this for the GUI specifically.
The states needed to set the property in the user interface would have a null Instrument property so getting the instrument would require you to first apply the script so its later states can run. After the script is already applied, you could reset the value overriding the users choice if necessary.
You can reset the value of the input after the fact in later states like DataLoaded when the Instrument property is not null but this would override the users choice. You could perhaps add logic in one of the later states to check for rollovers yourself. For example, if the Instrument is ES and your custom picker is ES but the rollover does not match, reset its value.
I look forward to being of further assistance.
Comment
-
Hi Jesse,Originally posted by NinjaTrader_Jesse View PostHello ballboy11,
You can use the following syntax to create an Instrument property:
Please let me know if I may be of further assistance.Code:protected override void OnStateChange() { if (State == State.SetDefaults) { InstrumentInput = Instrument.GetInstrument("ES 12-18"); } } [TypeConverter(typeof(NinjaTrader.Gui.Tools.InstrumentSelector))] [Display(Name="Select Instrument", GroupName = "Parameters", Order = 0)] public Instrument InstrumentInput { get; set; }
This method can not be serialized ; when saving a template we get an error
I am currently adding an [XmlIgnore()] to solve that, but of course, the parameter is not saved...
do you know a way to be able to serialize this ?
Pablo
Comment
-
Hello pmaglio,
Correct an Instrument is a complex object which cannot be serialized directly. This would be just like a brush if you wanted to save its value, you would need to write your own property for serialization in that use case. An Instrument its self is not expected to be serialized, you could try using a string of the instruments full name instead to avoid this.
You can find an example of serializing a brush, or the concept of making a serialization property here: https://ninjatrader.com/support/help...definedbrushes
I look forward to being of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
595 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
554 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment