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

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.
    Paul H.NinjaTrader Customer Service

    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

            Paul H.NinjaTrader Customer Service

            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 pechtri, 06-22-2023, 02:31 AM
              9 responses
              122 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by frankthearm, 04-18-2024, 09:08 AM
              16 responses
              64 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by habeebft, Today, 01:18 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by benmarkal, Today, 12:52 PM
              2 responses
              13 views
              0 likes
              Last Post benmarkal  
              Started by f.saeidi, Today, 01:38 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X