Announcement

Collapse
No announcement yet.

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

    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.

        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));

            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

                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.

                        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();

                            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

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                637 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                366 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                107 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                569 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                571 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X