Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Instrument drop down list
Collapse
X
-
Hello ballboy11,
You can use the following syntax to create an Instrument property:
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; }
JesseNinjaTrader Customer Service
-
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.
JesseNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Jesse View PostHello ballboy11,
You can use the following syntax to create an Instrument property:
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.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Brevo, Today, 01:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
3 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
242 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
384 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
||
Started by oviejo, Today, 12:28 AM
|
0 responses
6 views
0 likes
|
Last Post
by oviejo
Today, 12:28 AM
|
Comment