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 Mestor, 03-10-2023, 01:50 AM
              16 responses
              388 views
              0 likes
              Last Post z.franck  
              Started by rtwave, 04-12-2024, 09:30 AM
              4 responses
              31 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Started by yertle, Yesterday, 08:38 AM
              7 responses
              29 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by bmartz, 03-12-2024, 06:12 AM
              2 responses
              22 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by funk10101, Today, 12:02 AM
              0 responses
              7 views
              0 likes
              Last Post funk10101  
              Working...
              X