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!
See more
See less

Partner 728x90

Collapse

dropdown list of ATM Strategy

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

    dropdown list of ATM Strategy

    I want to have a dropdownlist of the ATM Strategies in my strategy. How is the typeconverter implemented. I tried different ways i don't know how to make a drop down list for the strategies

    #2
    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

    Comment


      #3
      I will look at my drop down list

      Comment


        #4


        //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


          #5
          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
          Unsuitable
          NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by terofs, Yesterday, 04:18 PM
          1 response
          21 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by CommonWhale, Today, 09:55 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by Gerik, Today, 09:40 AM
          2 responses
          7 views
          0 likes
          Last Post Gerik
          by Gerik
           
          Started by RookieTrader, Today, 09:37 AM
          2 responses
          13 views
          0 likes
          Last Post RookieTrader  
          Started by alifarahani, Today, 09:40 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X