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

Using Multiple MA Types in a Strategy

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

    Using Multiple MA Types in a Strategy

    Can you please point me to a Sample strategy that uses multiple MA types. I have a strategy that I would like to backtest with all different types. I would like them to be available in the strategy's properties dialog box.

    thanks

    #2
    Ken, I would suggest you review this sample for working with enums - http://www.ninjatrader.com/support/f...ead.php?t=3420
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Isn't it possible to access the
      NinjaTrader.Indicator.MAV.MAType without using a switch?
      Thanks

      Comment


        #4
        Ken, I'm not sure sure which indicator you refer to - simply declare the enum in your strategy and then assign a MA type for each case you need.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          DoubleMA Indicator lets you choose all different types of MA's but doesn't seem to be using this switch method. I'm referencing this indicator in my strategy buy I'm not sure how to access the MA Types. Can you shed some light on this issue?

          Comment


            #6
            The DoubleMA Indicator accesses the MAV Indicator which uses enum for 21 different MA's. Can I reference MAV or do I need to use enum the same way as MAV does?

            Comment


              #7
              Ken, you would need to review how the DoubleMA then calls and works with the MAV, then use the same approach in your strategy.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                I've added this to my strategy variables, which is the same as in the Indicator and it compiles OK

                private NinjaTrader.Indicator.MAV.MAType dMAFastType = NinjaTrader.Indicator.MAV.MAType.HMA;
                private NinjaTrader.Indicator.MAV.MAType dMASlowType = NinjaTrader.Indicator.MAV.MAType.SMA;

                I've added this to my strategy properties, which is the same as in the indicator and it compiles OK

                [Description("DMAFastType")]
                [Category(
                "Parameters")]
                public NinjaTrader.Indicator.MAV.MAType DMAFastType
                {
                get { return dMAFastType; }
                set { dMAFastType = value; }
                }
                [Description(
                "DMASlowType")]
                [Category(
                "Parameters")]
                public NinjaTrader.Indicator.MAV.MAType DMASlowType
                {
                get { return dMASlowType; }
                set { dMASlowType = value; }
                }

                But when I add this to Initialize, I get an error, "NinjaTrader Indicator.MAV.MAType' does not contain a definition fo 'DMAFastType' ...Code - CS0117" Didn't I establish the definition with the variables and properties? What am I missing? thanks

                Add(DoubleMA(DMAFastPeriod, NinjaTrader.Indicator.MAV.MAType.DMAFastType, DMASlowPeriod, NinjaTrader.Indicator.MAV.MAType.DMASlowType));

                Comment


                  #9
                  Hello kenb2004,

                  I've attached a sample strategy that allows the moving average selection from an indicator. It includes the SampleUniversalMovingAverage indicator. (our enum example)
                  Attached Files
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, I'll check it out.

                    Comment


                      #11
                      I'm sorry but I can't open this strategy .cs file. All I can open is the .xml file and it says it's version 7. Do you have a version 6.5 file?

                      Comment


                        #12
                        Attached is one for version 6.5
                        Attached Files
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Can you tell me why I get the error in thread #8?

                          Comment


                            #14
                            Ken, if I understood your correctly - you would not add the public properties in your strategy Initialize() but in the properties section of the script.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              In thread 8# the "public " is added to Properties, it's the "Add" line that is causing the propblem (see last line thread #8). Somehow I am defining the Indicator and it's property "MAType" wrong. Can you see the problem and solution? The whole issue is that I am trying to define 2 types, a fast and a slow from the Indicator DoubleMA. I want to be able to say FROM the strategy's property dialog box, use an EMA type for the DMAFastType, as "defined" in the Indicator DoubleMA and an SMA for the DMASlowType without having to hardcode it.

                              Somehow I think the real issue is that I am trying to define DMAFastType, which is defined in the Indicator DoubleMA but not in MAV which is the Indicator that DoubleMA gets it's MAType from. The problem seems to be defining the property of an Indicator of an Indicator, if that makes any sense. Any help?
                              Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ageeholdings, Today, 07:43 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post ageeholdings  
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post burtoninlondon  
                              Working...
                              X