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

Searching for SMMA

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

    Searching for SMMA

    Hello everyone,

    is there someone that has a Smoothed moving average (SMMA) or can code that for me? I'm attemping to do this but I've no experience in coding and it's very frustrating even if I think it's a pretty simple job:

    Smoothed Moving Average
    The first value of this smoothed moving average is calculated as the simple moving average (SMA):

    SUM.1 = SUM(CLOSE, n)
    SMMA.1 = SUM.1 / n

    The second and succeeding moving averages are calculated according to this formula:

    SMMA = (SUM.1 - SMMA.1+CLOSE) / n


    Thanks in advance,
    Best regards

    #2
    I don't have the time right this second... Here is a lot of help...

    DiNapoli reinvented everything, which was already invented and renamed it after DiNapoli ..... The only thing you need to do, is allow for broken periods greater than 1 . I have attached a generic EMA indicator, which allows you to enter fractional periods. The chart shows my new EMA Crossover System, which uses an EMA (38.3) and an EMA (12.7). :) this looks so similar to the ichimoku histogram, almost to the extent that if both were on same, they would overlap in ways that were confusing... so I would …


    Be sure to read post #4... it explains the the SMMA was used by Welles Wilder in the days before desktop computers and although it made life easier for Wilder in his day, unless you are replicating his work exactly in a research effort, its not of much use today..... which is why you don't see it handy on this site.

    Comment


      #3
      Originally posted by Crassius View Post
      I don't have the time right this second... Here is a lot of help...

      DiNapoli reinvented everything, which was already invented and renamed it after DiNapoli ..... The only thing you need to do, is allow for broken periods greater than 1 . I have attached a generic EMA indicator, which allows you to enter fractional periods. The chart shows my new EMA Crossover System, which uses an EMA (38.3) and an EMA (12.7). :) this looks so similar to the ichimoku histogram, almost to the extent that if both were on same, they would overlap in ways that were confusing... so I would …


      Be sure to read post #4... it explains the the SMMA was used by Welles Wilder in the days before desktop computers and although it made life easier for Wilder in his day, unless you are replicating his work exactly in a research effort, its not of much use today..... which is why you don't see it handy on this site.
      Thank you Crassius, I saw that post but that's not the MA I'm searching for, the Wilder version is a little different than the Smoothed..they say it's useless but I have a precise use off of it. I wrote the rules of the moving average in the first post and it's really simple but I made a lot of errors trying to code in Ninjascript..if you can do that when you have time I really appreciate..

      Comment


        #4
        Originally posted by Crassius
        Where did you get the formula you posted?

        Just looking at it without trying to code it it looks like it would not work... at least the way you have it written.

        This is the code as installed by default in MetaTrader4.... is this what you want?

        http://ta.mql4.com/indicators/trends/moving_average

        If not please give me the link to where you got the formula you posted as it does not appear complete.
        Hello and thanks for your interest. No it's not the default in MT4. It is exactly what in this BMT's post is called "The Simple SMMA":
        DiNapoli reinvented everything, which was already invented and renamed it after DiNapoli ..... The only thing you need to do, is allow for broken periods greater than 1 . I have attached a generic EMA indicator, which allows you to enter fractional periods. The chart shows my new EMA Crossover System, which uses an EMA (38.3) and an EMA (12.7). :) this looks so similar to the ichimoku histogram, almost to the extent that if both were on same, they would overlap in ways that were confusing... so I would …

        In the picture at the bottom of the post you can see that it is very similar to a SMA.

        Comment


          #5
          Here's SMMA

          I needed to nail down for my own purposes just what the default MetaTrader version of SMMA is....

          The barrier to entry of MetaTrader is very low... anyone with and email address can open a practice FX account can get a copy. The namespace of indicators in MetaTrader is terribly polluted with many people copying an indicator, slapping a new name on it and passing it around, sometimes in obscured code.

          I was confused by the various versions calling themselves SMMA out there, so I coded this indicator that includes a switch so the user can choose between the default SMMA that ships with MT4 and Wells Wilder's smoothing method used in the calculations of many of his indicators.

          I do not know the MetaTrader language, and MetaTrader's code for SMMA is more verbose than necessary to preform Wilder's smoothing. It was not until after I coded both versions that I knew for sure they both return exactly the same value.

          I post this here now for the original poster, so that he may see for himself through experimentation with this version that the two methods whose code looks different, are in fact returning the same values.

          It is more efficient to use the cleaner Wilder type code, so I will post a version of this that only includes that code in the file sharing section.

          For this version,

          I developed MT4's default SMMA with code step by step as similar to MT4's default SMMA as I could make it in NT.

          MT4's default SMMA equates to exactly the same value as an EMA of twice the length minus one. You can test this on MT4 by first plotting the default SMMA in one color, and then plotting an EMA of twice the SMMA's length minus one in another color....
          The EMA will exactly cover the SMMA.

          The attached SMMA when MT4version is selected does exactly the same thing, so I know I have a version in NinjaTrader that acts exactly like the MT4 version, which is what I was ultimately after for my own purposes.

          I then made a user selectable switch in the parameters section to select Welles Wilder's smoothing method found inside many of his indicators.

          As I don't code in MT4, it was not readily apparent to me that the MT4 version is just a verbose Wells Wilder method of smoothing, yet that is exactly what it is.

          I coded the Wilderversion closely following Wilder's verbal description from New Concepts in Technical Trading Systems... and find that it returns exactly the same value as the more verbose MT4 code version.

          Wilder describes the methodology of his smoothing on page 24 of the above mentioned book (and other places) thus,

          "Now let's review the procedure for calculating the ATR (Average True Range) on a daily basis. Initially, the ATR is obtained by taking the sum of the ranges for the first seven days and dividing this entire quantity by seven."

          SUM(input,7) or adding all inputs together whether close is the input or ATR is the input and dividing by the number of samples, is the same as taking a 7 period SMA
          on exactly the seventh bar and only the seventh bar and then storing that value.

          Wilder goes on, " For the eighth day; and thereafter, simply use the ATR for the previous day, multiply it by six." (this is one less than the period of seven we used in the first calculation)

          "add the true range for the latest day and divide this quantity by seven. By obtaining the ATR in this manner, we only have to keep up with data for the previous day."

          The last few words of that last sentence are why Wilder did his smoothing this way.

          Wilder was working in the days before desktop computers. By using his method he could work out the new value of ATR or what ever data he was smoothing... RSI or simply closes.... with fewer calculator key strokes.

          So attached for the original poster, I give two ways of coding SMMA that equate to exactly the same thing, and that both equate to an EMA of twice the length minus one.

          PS...

          To make things even more confusing, there is at least one other version in NinjaScript calling itself SMMA. This version is on BigMikeTrading and is discussed in post number three here:

          DiNapoli reinvented everything, which was already invented and renamed it after DiNapoli ..... The only thing you need to do, is allow for broken periods greater than 1 . I have attached a generic EMA indicator, which allows you to enter fractional periods. The chart shows my new EMA Crossover System, which uses an EMA (38.3) and an EMA (12.7). :) this looks so similar to the ichimoku histogram, almost to the extent that if both were on same, they would overlap in ways that were confusing... so I would …


          The poster in post three of the above BigMike thread describing this yet another version points out that in its code,

          "the term prevsmma1 is deducted twice, and the term Input[0] is added twice, once directly and once as part of sum1. "

          I believe this version of the SMMA is simply a badly coded attempt at the MT4 SMMA code. It names some of its variables the same as the MT4 code, but the code....perhaps because of the twice deducted Prevsmma1 etc.... returns some strange values not related to anything I have seen before.

          PPS...

          If you install this version, and later wish to install the more steamlined SMMA I will add to the file sharing section that will strip out the MT4 code, you will have to delete this one from the indicators folder first, as they will both have the name SMMA.
          Attached Files
          Last edited by Crassius; 03-12-2013, 03:00 AM.

          Comment


            #6
            Thank you very much Crassius, you had been very kind in giving your time for this. Well, I'm sorry to say that it's not the SMMA I'm searching for. I realized the Wilder it's the same as an EMA with *2-1 periods and that is equal to the Smoothed in MT4. I think the version I need is that named Simple SMMA in the post #1 here on the BMT thread:
            DiNapoli reinvented everything, which was already invented and renamed it after DiNapoli ..... The only thing you need to do, is allow for broken periods greater than 1 . I have attached a generic EMA indicator, which allows you to enter fractional periods. The chart shows my new EMA Crossover System, which uses an EMA (38.3) and an EMA (12.7). :) this looks so similar to the ichimoku histogram, almost to the extent that if both were on same, they would overlap in ways that were confusing... so I would …

            In fact the guy posts also a picture with the differences between those SMMA and you can see that it is very similar to a SMA. I will post an image from another platform so you can see the difference here. In this platform they define the Smooth in this way:
            "Smoothed Moving Average is similar to a simple moving average. However, in a
            smoothed moving average, rather than subtracting the oldest value the previous
            smoothed average value is subtracted." And here is the code even if it not seems of much help:
            INDICATOR

            PARAMETERS
            Period = 14 ( INTEGER_ONLY, MIN_VALUE=1, MAX_VALUE=1439 );

            BASES
            Base1;

            PLOTS
            IF_DEFINED(Base1.Close)
            Movs_Smooth = mov_smooth( Base1.Close, Period);

            END_INDICATOR

            Anyway thanks for your efforts I really appreciate.
            Attached Files

            Comment


              #7
              Originally posted by murena80 View Post
              Thank you very much Crassius, you had been very kind in giving your time for this. .

              I have to do this anyway for my own use, as this SMMA name has been corrupted by having more than one formula called SMMA. I needed to know which was which exactly.

              I think I finally backed into what you are after.

              Attached is a new indictor that includes the ability to switch between four versions of SMMA. The first three all equate to the exact same value, and are in fact Welles Wilder's smoothing.

              The fourth choice I have named SimpleSMMA from the terminology used in the BigMike thread.

              It is the culprit of the confusion because its author chose the same name as a widely known and distributed indicator that goes all the way back to Wilder's mid 1970's work.
              Attached Files

              Comment


                #8
                Ok this is exactly what I was searching for, thank you very much. Indeed there is a lot of confusion about this MAs, this Simple SMMA is quite different from the other three which are in reality one that was created by Wilder..and to add some confusion, you can find these versions called also Rolling MA in case you stumble upon it in the future. Thanks again..good job!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by arvidvanstaey, Today, 02:19 PM
                4 responses
                11 views
                0 likes
                Last Post arvidvanstaey  
                Started by samish18, 04-17-2024, 08:57 AM
                16 responses
                61 views
                0 likes
                Last Post samish18  
                Started by jordanq2, Today, 03:10 PM
                2 responses
                9 views
                0 likes
                Last Post jordanq2  
                Started by traderqz, Today, 12:06 AM
                10 responses
                18 views
                0 likes
                Last Post traderqz  
                Started by algospoke, 04-17-2024, 06:40 PM
                5 responses
                48 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X