Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enums or Drop-Down Lists as Strategy Parameters

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

    Enums or Drop-Down Lists as Strategy Parameters

    Hi,

    In strategy builder, the parameter selections include only the most typical variable types (int, string, etc.). What I am looking for is to be able to add a parameter that consists of an Enum or String List that is selectable by the user interface using drop-down or similar selection mechanism in the Strategies UI. I don't see any way to do this manually either with or without strategy builder.

    Am I missing something, or is this not supported?

    Thanks,

    Charlie

    #2
    Hello ChazJ,

    Thanks for your post and welcome to the NinjaTrader forums!

    The strategy builder is not capable of generating a drop down list.

    You can create this using Ninjascript, which is based on C# programming language, in the Ninjascript editor.

    Please see this working example from the help guide tips section: https://ninjatrader.com/support/help...ned_parame.htm

    You can also look at the indicator Pivots as another example of using Enums. The indicators code is available for viewing.

    Comment


      #3
      Thank you very much for your quick reply. It was very helpful. I was able to achieve what I was looking for by defining an enum in my Strategy code, then defining a default variable as that enum type with a default value in 'OnStateChange'. NT picked it up nicely and displays it in the Properties dialog as a drop-down list of values to choose from. Perfect.

      Thanks again.

      Comment


        #4
        For those who might find this topic in the future - forgot to add that I also had to define the Property:

        [NinjaScriptProperty]
        [Display(Name="MyAddedProperty", Description="Description", Order=3, GroupName="Parameters")]
        public PropertyType MyAddedProperty
        { get; set; }

        where PropertyType is the Enum I defined. This, I am sure, is the key to displaying it in the Properties Window of the Strategy.

        ChazJ

        Comment


          #5
          Originally posted by ChazJ View Post
          Thank you very much for your quick reply. It was very helpful. I was able to achieve what I was looking for by defining an enum in my Strategy code, then defining a default variable as that enum type with a default value in 'OnStateChange'. NT picked it up nicely and displays it in the Properties dialog as a drop-down list of values to choose from. Perfect.

          Thanks again.
          Could you share your strategy example file with enums? I see codes in indicators, but having trouble to transfer it to strategy script file.

          Comment


            #6
            Hello UltraNIX,

            Thanks for your post.

            Here is a link to an educational example in the help guide of working with an Enum: https://ninjatrader.com/support/help...ned_parame.htm

            Comment


              #7
              Thanks, I found the code in one of the strategies, adapted it for my strategy and it worked. However, I found another issue: https://ninjatrader.com/support/foru...-items-in-enum

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              56 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              132 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              49 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X