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

Volume Weighted EMA?

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

    Volume Weighted EMA?

    I spent 10+ hours trying to make one or figure it out and just couldn't figure out what I was doing wrong.

    If it's easy or something could someone post one?

    #2
    Originally posted by GGAG33 View Post
    I spent 10+ hours trying to make one or figure it out and just couldn't figure out what I was doing wrong.

    If it's easy or something could someone post one?
    Hi GGAG33, welcome to the forum!

    Have you tried our regular VWMA? This is like a normal SMA, but weighted by volume.

    Do you mind sharing any references you have for the Vol Weighted EMA you are talking about?

    Thanks!
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Can you at least translate it into how Ninjatrader calculates it for me?

      Here's the formula.

      VWEMA(t-1) + (K * [Price(t) * Volume(t) - VWEMA(t-1])
      ------------------------------------------------------
      VWEMA(t-1) (K * [Volume(t) - VWEMA(t-1)

      So can anyone translate into something that Ninjatrader would understand?

      Comment


        #4
        As a last resort you can try one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          GGA,

          Can you post the code.
          In order to translate this, we would need to know what
          - t is
          - K is
          mrlogik
          NinjaTrader Ecosystem Vendor - Purelogik Trading

          Comment


            #6
            Originally posted by mrlogik View Post
            GGA,

            Can you post the code.
            In order to translate this, we would need to know what
            - t is
            - K is
            T is Current bar

            T - 1 is the past bar

            K is 2 / (Period + 1)

            And I have nothing worthy of posting because its just 20+ errors in them + I can't figure out how the hell Ninjatrader calculates a EMA because it looks nothing like the real equation...

            This is Ninjatraders : Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]

            Normal: EMA(t - 1) + (K x [Price(t) - EMA(t - 1)]

            I suggest you guys change it, because all the other platforms I have tried besides this one is self explanatory. Most of the time it takes me like 10-15 minutes.

            Comment


              #7
              GGAG33,

              That is standard C# code. NinjaTrader is not built on a simple scripting language. You have the full power of a true programming language at your finger tips.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Josh View Post
                GGAG33,

                That is standard C# code. NinjaTrader is not built on a simple scripting language. You have the full power of a true programming language at your finger tips.
                I know that its C#, my problem is that how do I know what Input[0] is or Value[1] is?

                It says nothing about it.

                Comment


                  #9
                  Please see the Help Guide.


                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * Volume[0] (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]) / Input[1] * (K * Volume[0] - (1 - (2.0 / (1 + Period))) * Value[1]

                    Look right?

                    Comment


                      #11
                      GGAG33,

                      You will have to test the accuracy of the code yourself. We are not experts on the format you are trying to convert from and as such we are not in a position to advise you. Please see this tip on debugging that you can use to help determine if you are getting accurate values: http://www.ninjatrader-support.com/v...ead.php?t=3418
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Okay you guys I'm having a problem...

                        This is happening, but it only happens if I have the Volume[0] added to the regular EMA equation.

                        Any suggestions on how I can fix it.

                        Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * Volume[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
                        Attached Files

                        Comment


                          #13
                          Originally posted by GGAG33 View Post
                          This is happening, but it only happens if I have the Volume[0] added to the regular EMA equation.
                          The picture you uploaded looks fine to me. You're plotting the exponential moving average of price*volume. What did you expect? If you want to scale your result back down to price values, you need to divide your result by the EMA of volume.

                          That first formula you posted in this thread isn't even correct. A volume-weighted average is simply
                          (average of price*volume) / (average volume).
                          It doesn't matter if you calculate the 'average' as simple average, exponential average, or some other smoothing method. In your case, you want EMA(price*volume)/EMA(volume).

                          Once you understand what the indicator means, it becomes clear how to implement it. I'd do it something like this:
                          Code:
                          (variables)
                          private DataSeries pv;
                          
                          (initialization)
                          pv = new DataSeries(this);
                          
                          (onbarupdate)
                          pv.Set(Input[0] * Volume[0]);
                          double vema = EMA(Volume,period)[0];
                          if (vema == 0.0) vema=1.0;
                          Value.Set(EMA(pv,period)[0] / vema);
                          For brevity, I didn't include code to initialize the plot or declare 'period'.
                          -Alex
                          Last edited by anachronist; 10-08-2008, 10:52 AM.

                          Comment


                            #14
                            Has someone made an Volume Weighted EMA? I've tried it with the above guidance of Anachronist, however I didn't came much farther than the code that he quotes. Anyone else have an suggestion for how to proceed further?

                            Comment


                              #15
                              Hello,


                              Try the default indicator VWMA. There is also a VOLMA which is an EMA of VOL.

                              If neither of those meet your needs I suggest consulting one of our 3rd party NinjaScript Consultants here:
                              DenNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,404 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by Shai Samuel, 07-02-2022, 02:46 PM
                              4 responses
                              95 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by DJ888, Yesterday, 10:57 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              159 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Yesterday, 09:29 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Belfortbucks  
                              Working...
                              X