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

MACD of VMA ( Variable Index Dynamic Average)

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

    MACD of VMA ( Variable Index Dynamic Average)

    Hi Guys!
    I am not much handy with programming.So was wondering if i could get help from more experts here.I am trying to modify the default MACD indicator in Ninjatrader.What i want is replace the EMA in the indicator with VMA ( VIDYA) thats also a default in Ninja.But when i edited the default MACD and replaced all instances of EMA with VMA , it doesnt get compiled.I know it probably wont work this way as VMA has two input fields i.e Periods for smoothing and Periods for Volatility.Any help would be greatly appreciated.

    Regards
    UB

    #2
    Welcome to our forums UB, correct the VMA has two inputs instead of one for the regular EMA - so you would need to edit all calls to it to include the volatility parameter as well.

    Here's the helpguide page on the VMA and some example calls to see how it works - http://www.ninjatrader.com/support/h...riable_vma.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanx Bertfor your prompt reply!
      This is what i did:
      protected override void Initialize()
      {
      Add(new Plot(Color.Green, "Macd"));
      Add(new Plot(Color.DarkViolet, "Avg"));
      Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));

      Add(new Line(Color.DarkGray, 0, "Zero line"));

      fastVMA = new DataSeries(this);
      slowVMA = new DataSeries(this);
      }

      /// <summary>
      /// Calculates the indicator value(s) at the current index.
      /// </summary>
      protected override void OnBarUpdate()
      {
      if (CurrentBar == 0)
      {
      fastVMA.Set(int period, int volatilityPeriod);
      slowVMA.Set(int period, int volatilityPeriod);
      Value.Set(0);
      Avg.Set(0);
      Diff.Set(0);
      }
      else
      {
      fastVMA.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * fastVMA[1]);
      slowVMA.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * slowVMA[1]);

      double macd = fastVMA[0] - slowVMA[0];
      double macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * Avg[1];

      Value.Set(macd);
      Avg.Set(macdAvg);
      Diff.Set(macd - macdAvg);
      }
      }
      And it still doesnt work!
      UB

      Comment


        #4
        UB, thanks for the reply - this cannot work - the EMA formulas used here are coded out and therefore could not be easily replaced as you initially thought. You would need to contract the indicator fresh.

        So for example the basic MACD line would the be (you would need to test which parameters to use):

        double value = VMA(Close, 12, 6)[0] - VMA(Close, 26, 13)[0];

        Finally you would then smooth this value again to arrive at the MACD average value.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks Bert for the help! I will try to do it after going through some manuals on Ninja programming.

          UB

          Comment


            #6
            You're welcome - a good start would be those - http://www.ninjatrader.com/support/h.../tutorials.htm
            BertrandNinjaTrader Customer Service

            Comment


              #7
              a better VIDYA

              unless i'm mistaken, the NT version is based on StDev. the improved version uses a dimensionless market value that ranges from 0 to 1. checkout pg 58 of the book by Chande & Kroll. you can use ANY oscillator to calculate VIDYA so long as it is dimensionless and varies from 0 to 1. personally, i use R Squared. with this i can use a 1000 period moving average that will compete with and frequently beat a 10 period moving average. the reason i don't post this improved indicator is that it cost me $hundreds$ to have coded by one of the NT certified script consultants.
              in my experience, any time the VIDYA is offered in a software program, it's the StDev version. any one familiar with fractals or madelbrot knows that prices are not normally distributed. like i said at the top, there is a better VIDYA available.
              why i point this out now is because, i'm currently in development of even better and more reliable volatility indicators. for all those not already in "the know" this improved VIDYA will certainly improve your results.
              for all those not familiar with the wonders of VIDYA, too bad for them. happy trading!!
              JM

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Yesterday, 10:35 PM
              5 responses
              18 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              13 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              12 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              8 views
              0 likes
              Last Post nandhumca  
              Working...
              X