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

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.
    https://ninjatrader.com/support/foru...ameters-in-nt8
    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.
              https://ninjatrader.com/support/help...yattribute.htm
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by RaddiFX, Yesterday, 11:57 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Marco  
              Started by Tonofit, Today, 12:00 AM
              0 responses
              1 view
              0 likes
              Last Post Tonofit
              by Tonofit
               
              Started by ck6libra, Yesterday, 11:20 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by witipica, Yesterday, 10:02 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_ChrisSch  
              Started by rtwave, Yesterday, 09:52 PM
              0 responses
              8 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Working...
              X