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

    #16
    Ken, unfortunately we could not debug this for you - there are 2 options -

    a) work alongside the example Ryan has provided you with (using our Sample Universal MA as base)

    b) implement the same call structure the Double MA would use to work with the MAV indicator
    BertrandNinjaTrader Customer Service

    Comment


      #17
      I chose plan b) and it did not work. How is 'DMAFastType' not defined? My private variable in my strategy is identical to the DoubleMA's variable.

      DoubleMA Indicator variables
      private NinjaTrader.Indicator.MAV.MAType dMAFastType = NinjaTrader.Indicator.MAV.MAType.EMA;
      private NinjaTrader.Indicator.MAV.MAType dMASlowType = NinjaTrader.Indicator.MAV.MAType.SMA;
      Strategy variables
      private NinjaTrader.Indicator.MAV.MAType dMAFastType = NinjaTrader.Indicator.MAV.MAType.EMA;
      private NinjaTrader.Indicator.MAV.MAType dMASlowType = NinjaTrader.Indicator.MAV.MAType.SMA;

      Comment


        #18
        NinjaScript is case sensitive - DMA is not the same as dMA - you would need to take a look at Double MA's public properties as well which the DMA capitalized would be.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          Thanks, I am aware of case sensitivity. As you can see in thread#8 I have used lowercase in private variables, Upper in public properties and lower in 'get' and 'set'. And I have done the same in my strategy, which all compiles properly. It's not until I
          Add the indicator to Initialize() that the 'definition' error appears. "NinjaTrader Indicator.MAV.MAType' does not contain a definition fo 'DMAFastType' .

          My question is why does MAV need a definition when I'm getting the definition from DoubleMA? Is this a NinjaTrader glich or a Ken glich? Should I be using the same approach as DoubleMA uses or should it be DoubleMA's definition and not MAV's?

          Comment


            #20
            Ken, it seems you pass in the an invalid input type as you Add() it - did you try casting to Ints?

            Add(MAV( MAV(Input, MA1Period, (int)MA1Type ), MA2Period, (int)MA2Type));
            BertrandNinjaTrader Customer Service

            Comment


              #21
              I did try adding this MAV line with the same definition error. I tried it both ways, substituting MA1Type for DMAFastType and vice versa with the same error. It does seem as though the definition of an indicator's indicator type is the problem.
              Thanks for your efforts....

              Comment


                #22
                Ken, please check the attached strat for 6.5 - this will work in calling the MAV.
                Attached Files
                BertrandNinjaTrader Customer Service

                Comment


                  #23
                  Thanks, I'll check it out.

                  Comment


                    #24
                    Hello,
                    I'm getting a similar issue with this indicator. I downloaded the MavStrat.zip, but that didn't fix my issue. The error message I keep getting is:
                    "'Ninja Trader.Indicator.MAV' is a 'type', which is not valid in the given context". In post #21 Ken2004 wrote " It does seem as though the definition of an indicator's indicator type is the problem." I believe that is my issue, but I don't know how to fix it.
                    In the Variable section of the Channel This indy it reads:
                    private NinjaTrader.Indicator.MAV.MAType mA1Type = NinjaTrader.Indicator.MAV.MAType.HMA;
                    Any suggestions as to this error?

                    Comment


                      #25
                      Please disregard my previous post. I imported the wrong Mav.zip. So I installed Bertrand's fix (thank you very much) and I'm no longer getting errors, but the indicator added turn's out to be the center line of the Channel This. I really am looking to trade inside the channel. I found in the Channel This code the following:
                      Low.Set(DoubleMA(MA1, MA1Type, MA2, MA2Type).DMV[0] - ATR(ATRlength)[0] * ATRmulti);
                      Mid.Set(DoubleMA(MA1, MA1Type, MA2, MA2Type).DMV[0]);
                      High.Set(DoubleMA(MA1, MA1Type, MA2, MA2Type).DMV[0] + ATR(ATRlength)[0] * ATRmulti);
                      I'm wondering if there is an easy way to add that to Bertrand's fix in order to get the channel feature.

                      Comment


                        #26
                        CaptainAmericaXX, you could surely add to my simple strategy call provided - the double MAV call + the ATR would for example be the upper channel boundary then it seems, same would go for the lower one.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #27
                          Bertrand,
                          Thanks for the reply. Could you throw me another bone. I've been working on adding the above, but my programming knowledge is limited. A suggestion of how to add that information would be greatly appreciated.

                          Comment


                            #28
                            You could for example try a condition such as this one -

                            if (Close[0] > MAV( MAV(Input, MA1Period, (int)MA1Type ), MA2Period, (int)MA2Type)[0] + ATR(Close, 14)[0] &&
                            Close[1] < MAV( MAV(Input, MA1Period, (int)MA1Type ), MA2Period, (int)MA2Type)[1] + ATR(Close, 14)[1])

                            EnterLong();
                            BertrandNinjaTrader Customer Service

                            Comment


                              #29
                              I am also trying to recreate the appearance of the channel in the indicator. Can you give me an example of how to add the ATR to MAV indicator so I can create this channel? The original Channel This had variable of ATR(ATRlength) & ATRmulti. I would really like to see this thing working like the original.

                              Comment


                                #30
                                It would be easiest then to create an indicator that displays the values you need and then call this in your strategy as well so you can visualize it better, another option would be debugging / adapting the original ChannelThis custom indicator code...if you look to add user inputs for parameters to your strategies, please see this tip going over the details - http://www.ninjatrader.com/support/f...ead.php?t=5782
                                BertrandNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by algospoke, Yesterday, 06:40 PM
                                2 responses
                                18 views
                                0 likes
                                Last Post algospoke  
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                44 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                20 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                180 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X