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

Is it possible to create a cumulative moving average?

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

    Is it possible to create a cumulative moving average?

    Is it possible to create a cumulative moving average?

    Anyone has any idea how to make it and if somewhere in this forum there is information about it with clear steps to follow?

    I'm a newbie at this and i have no idea how to program an indicator.

    Any book or website somewhere?

    thanks in advance

    #2
    frankduc,

    Best place to start is with these tutorials: http://www.ninjatrader-support.com/H...tml?Overview23

    As far as making a cumulative moving average, you would need to define out exactly what this means first. Figure out what logic you want to use and then after that you can put it into the coding of the indicator.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      i already made one on excel

      Its the same as a sample moving average, but instead of counting lets say the last 10 periods it cumulate the periods.

      With the SMA wherever you start it counts the last 10.

      With CMA it count period 1 (then draw a line for one)
      period 2 (same line but count 2 period)
      period 3 (same line but count 3 period)
      etc, till the 10th period

      I'm reading the page you linked too, pretty complicated :-(

      Comment


        #4
        frankduc,

        It can be done but would require custom programming. Unfortunately we do not offer this service, but if you want you could try one of these 3rd party NinjaScript Consultants who do: http://www.ninjatrader.com/webnew/pa...injaScript.htm
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          A Cumulative moving average is price over time (candle count)

          CMATotal = CMATotal + CurrentClosePrice;
          CMACounter = CMACounter + 1;
          CMA = CMATotal / CMACounter;

          Plot this CMA to the current price chart like any other moving aveage.

          The CMA needs to be reset, which will depend upon the time frame you are working with.

          Say using a 30 Minute chart you might want to reset it at the beginning of the day or session.

          Reset the CMA by setting the two variables back to zero:
          CMATotal = 0;
          CMACounter = 0;

          For a Tradestation example:
          Blogger is a blog publishing tool from Google for easily sharing your thoughts with the world. Blogger makes it simple to post text, photos and video onto your personal or team blog.

          Comment


            #6
            What should i change in there to make it works?

            int numBars = Math.Min(CurrentBar, period);

            double volPriceSum = 0;
            double volSum = 0;

            for (int i = 0; i < numBars; i++)
            {
            volPriceSum += Input[i] * Volume[i];
            volSum += Volume[i];
            }

            // Protect agains div by zero evilness
            if (volSum <= double.Epsilon)
            Value.Set(volPriceSum);
            else
            Value.Set(volPriceSum / volSum);


            I'm not a programmer so i have no idea what must been done.
            I understand the big idea, but if i change the codes it never works.

            Thanks for the info.

            Comment


              #7
              frankduc,

              What are you trying to achieve with the code? What is the end result you wish to see?
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                That code calculates the VWAP. The "File Sharing" section has a very well and complete VWAP available for free download.

                Comment


                  #9
                  Well i thought it would of been easier to create a cumulative moving average out of a volume weighted moving average.

                  Theres a free code for the VWMA but not the CWMA. If there's one its new to me. The cumulative is just the basis to create somethin more elaborate. In any case i will need a programmer to enter several math formula.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by geddyisodin, Today, 05:20 AM
                  2 responses
                  16 views
                  0 likes
                  Last Post geddyisodin  
                  Started by hazylizard, Today, 08:38 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post hazylizard  
                  Started by Max238, Today, 01:28 AM
                  5 responses
                  43 views
                  0 likes
                  Last Post Max238
                  by Max238
                   
                  Started by giulyko00, Yesterday, 12:03 PM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by habeebft, Today, 07:27 AM
                  1 response
                  16 views
                  0 likes
                  Last Post NinjaTrader_ChristopherS  
                  Working...
                  X