Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What type of variable is used for this?

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

    What type of variable is used for this?

    Hi,

    I am trying to program a variable like this photo 1.

    That is, I need to create a variable that can take several different values ​​so that later I can optimize it.

    Thank you

    #2
    Hi lju45,
    This is an "enum". Enums can provide great benefit in various different scenarios. To pick different MA types is one of them.
    Here is a link to an earlier post on this.

    NT-Roland

    Comment


      #3
      Hi lju45,

      NT-Roland is correct this is an enum.

      Just an update, this reference sample is now maintained in the help guide.
      https://ninjatrader.com/support/help...ned_parame.htm
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you,

        If I want to use it in a strategy, how can I declare the type of MA? I mean, I can create an enum variable to select type (EMA, HMA ..) but then how Can I declare this type in the strategy? I want to have something like this: private _?__ MA1; So depending enum variable, this declaration is different. Is it possible?

        Comment


          #5
          Hello lju45,

          In the SampleUniversalMovingAverage reference sample see lines 52 through 85 where it is demonstrated how to switch between the selected moving average type used for the Value[0].

          If you want to save the indicators to variables, you will need to make a variable for every indicator. There would be no switch for this.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you, I have used the same as in the example, but when I go to Strategy Analyzer -> Optimization, I can't seem to optimize the MA type. How do I get to optimize that variable?
            Attached Files

            Comment


              #7
              Hi lju45,

              Use the [NinjaScriptProperty] attribute to make an input optimizable.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              577 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X