• 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 pstrusi, Today, 03:29 PM
    2 responses
    9 views
    0 likes
    Last Post pstrusi
    by pstrusi
     
    Started by ntbone, Today, 03:06 PM
    0 responses
    4 views
    0 likes
    Last Post ntbone
    by ntbone
     
    Started by AMATX, Today, 01:43 PM
    2 responses
    7 views
    0 likes
    Last Post AMATX
    by AMATX
     
    Started by razeus, Today, 12:00 PM
    4 responses
    17 views
    0 likes
    Last Post razeus
    by razeus
     
    Started by kitwit, Today, 09:47 AM
    5 responses
    24 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X