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.

    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 Waxavi, Today, 02:10 AM
              0 responses
              4 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              10 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by elirion, Today, 01:36 AM
              0 responses
              4 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by gentlebenthebear, Today, 01:30 AM
              0 responses
              4 views
              0 likes
              Last Post gentlebenthebear  
              Working...
              X