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
dropdown list of ATM Strategy
Collapse
X
-
Hello ballboy11,
This would be outside of what is supported by NinjaTrader Support.
That said, I looked around and found some internal conversation within the company that was not publicly posted on the forums you may find helpful.
Code:public class FriendlyAtmConverter : TypeConverter { // Set the values to appear in the combo box public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { List<string> values = new List<string>(); string[] files = System.IO.Directory.GetFiles(System.IO.Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "templates", "AtmStrategy"), "*.xml"); foreach(string atm in files) { values.Add(System.IO.Path.GetFileNameWithoutExtension(atm)); NinjaTrader.Code.Output.Process(System.IO.Path.GetFileNameWithoutExtension(atm), PrintTo.OutputTab1); } return new StandardValuesCollection(values); } public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return value.ToString(); } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { return value; } // required interface members needed to compile public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return true; } public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return true; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } }
Code:[TypeConverter(typeof(FriendlyAtmConverter))] // Converts the found ATM template file names to string values [PropertyEditor("NinjaTrader.Gui.Tools.StringStandardValuesEditorKey")] // Create the combo box on the property grid [Display(Name = "Atm Strategy", Order = 1, GroupName = "AtmStrategy")] public string AtmStrategy { get; set; }
Chelsea B.NinjaTrader Customer Service
- Likes 1
-
//This is in my parameters
[TypeConverter(typeof(FriendlyAtmConverter))] // Converts the found ATM template file names to string values
[PropertyEditor("NinjaTrader.Gui.Tools.StringStanda rdValuesEditorKey")] // Create the combo box on the property grid
[Display(Name = "Atm Strategy", Order = 1, GroupName = "AtmStrategy")]
public string AtmStrategy
{ get; set; }
public class YourStrategyName : Strategy // Dont add this
{
// Place this Section under your strategy name
public class FriendlyAtmConverter : TypeConverter
{
// Set the values to appear in the combo box
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
List<string> values = new List<string>();
string[] files = System.IO.Directory.GetFiles(System.IO.Path.Combin e(NinjaTrader.Core.Globals.UserDataDir, "templates", "AtmStrategy"), "*.xml");
foreach (string atm in files)
{
values.Add(System.IO.Path.GetFileNameWithoutExtens ion(atm));
// NinjaTrader.Code.Output.Process(System.IO.Path.Get FileNameWithoutExtension(atm), PrintTo.OutputTab1);
}
return new StandardValuesCollection(values);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
return value.ToString();
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
return value;
}
// required interface members needed to compile
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{ return true; }
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{ return true; }
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{ return true; }
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{ return true; }
}
This will work for your strategy template parameters
Comment
-
Hello,
I was linked to this thread for a similar question. As this relates to dropdowns and enums, checkout this thread for dropdowns based on special characters. Perhaps somebody will find it useful. It's always good to cross-pollinate code solutions.
Dropdowns based on special characters
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by brunoviveiros, 02-17-2020, 05:31 AM
|
4 responses
63 views
0 likes
|
Last Post Today, 06:25 AM | ||
Started by volIQ, 03-27-2024, 04:28 PM
|
3 responses
21 views
0 likes
|
Last Post
by RJay
Today, 05:41 AM
|
||
Started by Nickgiaco, 02-26-2024, 10:23 AM
|
2 responses
72 views
0 likes
|
Last Post Today, 05:12 AM | ||
Started by Johndc, Today, 04:39 AM
|
0 responses
8 views
0 likes
|
Last Post
by Johndc
Today, 04:39 AM
|
||
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
11 views
0 likes
|
Last Post Today, 02:34 AM |
Comment