• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating Properties, with drop-down list of all available ATM strategies

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Creating Properties, with drop-down list of all available ATM strategies

    I am developing a strategy in NinjaScript NT8, and would like to have "ATM Strategy" as a property. That field would contains a drop-down list showing "Active" and all my available ATM strategies. The thought is I would use this value when executing an order basing it on either the current active strategy in the Chart Trader, or the ATM strategy chosen from the drop-down list.

    In addition, is there a technique to get the "Active" ATM strategy, i.e., the one currently displayed under ATM Strategy in the Chart Trader?

    Do you have code samples to achieve this?

    #2
    Hello epete,

    Thank you for your post.

    I have attached an example that demonstrates how to create a custom ATM selector in your script. To import the script, go to Tools>Import.

    First, you add a TypeConverter class within the Strategy class that scans the Documents\NinjaTrader 8\templates\AtmStrategy directory.

    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; }}
    Then use that class as a property in the script:

    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; }
    It looks like there is currently not a way to access the active ATM strategy from within a script. I will need to look into this further.

    Please let me know if I can assist any further.
    Attached Files
    Last edited by NinjaTrader_ChrisL; 04-08-2019, 02:21 PM.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by iishkuatcyta, Today, 02:43 AM
    0 responses
    1 view
    0 likes
    Last Post iishkuatcyta  
    Started by curious, Today, 02:17 AM
    2 responses
    6 views
    0 likes
    Last Post curious
    by curious
     
    Started by pmmkm, Yesterday, 11:13 PM
    0 responses
    3 views
    0 likes
    Last Post pmmkm
    by pmmkm
     
    Started by pulpiwapi, 03-04-2019, 11:18 PM
    11 responses
    149 views
    0 likes
    Last Post music_p13  
    Started by indy73, 06-25-2019, 10:52 PM
    3 responses
    21 views
    0 likes
    Last Post sledge
    by sledge
     
    Working...
    X