NexusFi: Find Your Edge


Home Menu

 





The Smoothed Moving Average or SMMA - How to Avoid It


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 6 posts (41 thanks)
    2. looks_two kronie with 2 posts (1 thanks)
    3. looks_3 Big Mike with 1 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one Fat Tails with 6.8 thanks per post
    2. looks_two fluxsmith with 6 thanks per post
    3. looks_3 Big Mike with 2 thanks per post
    4. looks_4 omaha786 with 1 thanks per post
    1. trending_up 29,145 views
    2. thumb_up 51 thanks given
    3. group 7 followers
    1. forum 13 posts
    2. attach_file 6 attachments




 
Search this Thread

The Smoothed Moving Average or SMMA - How to Avoid It

  #1 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

I had recently stumbled upon the smoothed moving average or SMMA, which is used by many other indicators such as shaded moving averages, the Supertrend and channel indicators. I had then simplified the code , but the indicator left me confused, as I had no idea, what it is needed for.

The code I found on the forum has the following core
 
Code
if (FirstTickOfBar)
{
	prevsum1 = sum1;
	prevsmma1 = smma1;
}
Value.Set((prevsum1-prevsmma1+Input[0])/Period);
sum1 = prevsum1-prevsmma1+Input[0];
smma1 = (sum1-prevsmma1+Input[0])/Period;
which I changed into
 
Code
Value.Set((1-2.0/Period)*Value[1]+ (Value[2]+Input[0])/Period);
This looks interesting, but it is not easy to see what it is actually doing. So I searched the Internet to get more information and found that there is not a single version of the SMMA but that two different versions exist. Let us call the the 2 versions “Useless” and “Simple”.


The Useless SMMA

Taking a look at the SMMA proudly presented by WealthLab, I found the following formula, here translated to NinjaScript
 
Code
Value.Set(Value[1] - Value[1]/Period + Input[0]/Period);
This formula clearly points to an exponential moving average with the known formula EMA = (k-1)/k * EMA[1] + 1/k * Price,
where k = 2/(period+1).

And indeed, the SMMA when used with a Period n returns the same result as an EMA, when used with a period 2*n – 1. For example, the following equalities apply:

SMMA (12) = EMA(23)
SMMA (13) = EMA(25)
SMMA (14) = EMA(27)

This means that this SMMA version is indeed completely useless, as it returns the same results as an EMA. It just uses a false period and cannot be fine tuned to display EMAs with even periods. This is an indicator for the garbage bin. You will find this version of the SMMA for WealthLab, Metastock, MetaTrader 5, FXCM

Sources:
SMMA (Smoothed [AUTOLINK]Moving Average[/AUTOLINK] Series) - Wealth-Lab Wiki
Equis International Online Community - How to run this formula up to Metastock?
Moving Average - Help
FXCodeBase.COM: Forex Chart Indicators and Development • View topic - SMMA - Smoothed [AUTOLINK]Moving Average[/AUTOLINK] (SMMA) [Update Aug 27 2010]
Smoothed [AUTOLINK]Moving Average[/AUTOLINK] (SMMA) - DailyFX Forex Forum | FX Forum


The Simple SMMA

The simple version of the SMMA is similar to the useless one, the NinjaScript formula for the core is
 
Code
Value.Set (SMA(Period)[1] – Value[1]/Period + Input[0]/Period);
which comes close to the useless SMA, which uses SMMA(Period)[1] in place of SMA(Period)[1] for the first term of the expression above.

This moving average is easier to understand. It takes the previous value of the SMA and then adds a correctional term, which is 1/Period multiplied with the difference of current Price and the previous value of the SMMA. As it always starts calculating by using last period’s simple moving average, it produces a smoothed moving average, which closely tracks the SMA. This is a modest achievment, but still better than no achievement. A chart showing a simple moving average and the two versions of SMMA is attached.

Sources:

Investor/RT Tour - Moving Averages
Moving Average - Trends Indicators - Technical Indicators - Technical Analysis
Moving Average (MA)

Attached Thumbnails
Click image for larger version

Name:	ES 03-11 (15 Min) 16_02_2011 SMMA.jpg
Views:	1197
Size:	100.7 KB
ID:	31093  
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
Futures True Range Report
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


The SMMA version, which I found on Big Mike's Forum is neither the Useless nor the Simple SMMA, but it is a variation of the Useless SMMA. Let us have a look at the code again:

 
Code
if (FirstTickOfBar)
{
	prevsum1 = sum1;
	prevsmma1 = smma1;
}
Value.Set((prevsum1-prevsmma1+Input[0])/Period);
sum1 = prevsum1-prevsmma1+Input[0];
smma1 = (sum1-prevsmma1+Input[0])/Period;
The mechanics are similar as the definition of the Useless SMA, but to calculate smma1, which is the current value of the smma, the term prevsmma1 is deducted twice, and the term Input[0] is added twice, once directly and once as part of sum1. Whether this was intentional or by mistake, it creates a new breed of SMMA, which is slightly different compared to the original version and which I will refer to as the Forum SMMA. In my version of the formula this translates into the additional term shown in bold below

 
Code
Value.Set((1-1.0/Period)*Value[1] - (Value[2] - Value[1])/Period  + Input[0])/Period);
This term represents a fraction 1/Period of the difference between SMMA[1] and SMMA[2]. The outcome is a moving average which closely tracks the EMA, but has some additional lag. Actually I do not have any argument to use the Forum SMMA in place of the EMA, so it looks redundant to me as well.

If there is anybody around, who can explain to me, whether the error term is intentional or erroneous, I would like to know. Practically, I have no use for the additional lag introduced.


Conclusions:

All SMMAs I have found have either little practical value, or even worse are redundant or misleading. I do not see any practical value for trading and have no use for them and will not further waste my time with them.

NinjaTrader has a nice feature allowing you delete useless and redundant indicators. I will also modify my other indicators which produce channels or crosses from various moving averages, not to call the SMMA. There is no value added, but value reduced. If anyone has used the Forum SMMA until now, I recommend using the EMA instead.

Due to its additional lag, the Forum SMMA can better be approximated by an EMA with a slightly increased period, so you would replace the Forum SMMA(8) with an EMA(17), compare this with the EMA(15), which is the identical replacement for the SMMA(8).


All SMMAs belong to the Garbage Bin. They were just created to waste your time!

Attached Thumbnails
Click image for larger version

Name:	ES 03-11 (15 Min) 16_02_2011 Forum SMMA.jpg
Views:	675
Size:	77.7 KB
ID:	31095  
Started this thread Reply With Quote
  #4 (permalink)
 fluxsmith 
Santa Maria
 
Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Broker: Mirus/Zen-Fire
Trading: ES
Posts: 290 since May 2010
Thanks Given: 97
Thanks Received: 322


Fat Tails View Post
The Useless SMMA

Taking a look at the SMMA proudly presented by WealthLab, I found the following formula, here translated to NinjaScript
 
Code
Value.Set(Value[1] - Value[1]/Period + Input[0]/Period);
This formula clearly points to an exponential moving average with the known formula EMA = (k-1)/k * EMA[1] + 1/k * Price,
where k = 2/(period+1).

And indeed, the SMMA when used with a Period n returns the same result as an EMA, when used with a period 2*n – 1.

I thought that looked familiar... In fact the indicator I've posted as jhlMMA essentially is:
 
Code
class MMA : JHL.Utility.EMA {
   public MMA(int periods) : base(Math.Max(1, periods) * 2 - 1)
   {
   }
}

While I agree it's really quite useless, it is actually the Welles Wilder MA method which makes it an essential ingredient in other indicators such as ADX.

From my description in the download section:
Wikipedia calls this a 'Modified Moving Average'. Traders may know it as Welles Wilder's Moving Average, as it is the averaging method used in many of his indicators.

It's conceptually simpler than an EMA, the basic formula being:
average = (newValue + priorAverage * (n - 1)) / n

However, for any number of periods 'n', the outcome is identical to EMA(2 * n - 1).

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


fluxsmith View Post
While I agree it's really quite useless, it is actually the Welles Wilder MA method which makes it an essential ingredient in other indicators such as ADX.

From my description in the download section:
Wikipedia calls this a 'Modified Moving Average'. Traders may know it as Welles Wilder's Moving Average, as it is the averaging method used in many of his indicators.

It's conceptually simpler than an EMA, the basic formula being:
average = (newValue + priorAverage * (n - 1)) / n

However, for any number of periods 'n', the outcome is identical to EMA(2 * n - 1).


Thanks for this comment. The Useless SMMA is indeed identical with Welles Wilder's average. The point is that Welles Wilder was not really interested in different types of moving averages, but from a practical point of view he looked for a method allowing him

-> to make as little calculations as possible, as he did not have a PC performing this task back in the 70s, and the exponential smoothing is ideal as you just use the prior value of the average and current price to calculate the new value

-> use an average that does not bite good-bye when the first element drops out as does the SMA

With the article by Jack K.Hutson "Filter Price Data: Moving Averages versus Exponential Moving Averages". which appeared in the May/June 1984 issue of Technical Analysis of Stocks and Commodities, it was shown that the equivalent of a simple moving average with the period n was obtained by using a smoothing constant 2/(n+1) for the exponential smoothing. From there on, the current definition of the period of an EMA was used and now is the standard for EMAs.

So there is no need to go back to an alternative definition for the period as used by Welles Wilder in the 70s for practical purposes. All indicators that use Wilder's smoothing can alternatively use an EMA.

Started this thread Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534

One down, 25,000 to go!

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Big Mike View Post
One down, 25,000 to go!

Mike


Started this thread Reply With Quote
  #8 (permalink)
 omaha786 
San Diego, California
 
Experience: Intermediate
Platform: Sierra Chart
Broker: IB, OEC, Optimus, DDT
Trading: ES, ZN
Posts: 221 since Jun 2010
Thanks Given: 512
Thanks Received: 158

EMA uses a recursive formula. The period in the EMA doesn't make sense since it uses all of the bars to calculate the current value although the early bars have less effect. A generalized EMA should be:

ema(0) = c(0)
ema(n) = k * c(n) + (1 - k) * ema(n-1)

where 0 < k < 1 is a constant, it can be any constant between 0 and 1.

DiNapoli used this generalized EMA to construct his own version of MACD (DiNapoli MACD).

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #9 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


omaha786 View Post
EMA uses a recursive formula. The period in the EMA doesn't make sense since it uses all of the bars to calculate the current value although the early bars have less effect. A generalized EMA should be:

ema(0) = c(0)
ema(n) = k * c(n) + (1 - k) * ema(n-1)

where 0 < k < 1 is a constant, it can be any constant between 0 and 1.

DiNapoli used this generalized EMA to construct his own version of MACD (DiNapoli MACD).

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

Attached Thumbnails
Click image for larger version

Name:	6E 03-11 (15 Min) 16_02_2011.jpg
Views:	743
Size:	95.9 KB
ID:	31128  
Attached Files
Elite Membership required to download: GenericEMA.zip
Started this thread Reply With Quote
  #10 (permalink)
murena80
Roma, Italia
 
Posts: 1 since Mar 2013
Thanks Given: 0
Thanks Received: 0


Hello Fat Tails,

I am searching about that SMMA you talked about here. In particular the version you named "The Simple SMMA", even if it seems useless I have a strategy, in which it have a part, that I'm migrating to NT from another platform. If you kindly can share that indicator I really appreciate.

Best regards
Andrea

Reply With Quote




Last Updated on March 23, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts