Any assistance is greatly appreciated.
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
list of instruments
Collapse
X
-
list of instruments
Hi, in my indicator I would like a drop down list in the parameter settings section of all available instruments in my "Default" instrument list. My indicator is designed to run based off of another instrument that correlates to the one defined for the chart. This list will enable me to select which instrument I want to correlate.
Any assistance is greatly appreciated.Tags: None
-
Hello FCatan,
Thank you for your inquiry.
Please note that this method is only an example and is unsupported. This will be only pulling the FullName string from the instrument list.
Please ensure that you have using System.Collections.Generic; in your using declarations.
Code:protected override void Initialize() { NinjaTrader.Cbi.InstrumentList listOfInstruments = NinjaTrader.Cbi.InstrumentList.GetObject("Default"); List<string> AvailableInstruments = new List<string>(); foreach (Instrument instrument in listOfInstruments.Instruments) { AvailableInstruments.Add(instrument.FullName); } ArrayAvailableInstruments = AvailableInstruments.ToArray(); } private string theListOfInstruments; [Description("Instruments")] [GridCategory("Parameters")] [TypeConverter(typeof(StringListConverter))] public string TheListOfInstruments { get { return theListOfInstruments; } set { theListOfInstruments = value; } } [Browsable(false)] public string[] ArrayAvailableInstruments { set { StringListConverter.value = value; } }
Code:public sealed class StringListConverter : StringConverter { public static string[] value; public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return new StandardValuesCollection(value); } }
I would suggest reading more about the use of type converters in C#: https://msdn.microsoft.com/en-us/library/ayybcxe5.aspxZachary G.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by helpwanted, Today, 03:06 AM
|
1 response
8 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Brevo, Today, 01:45 AM
|
0 responses
7 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
5 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
385 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
Comment