Exponential Moving Average

Discussion in 'Trading' started by rrisch, Apr 14, 2002.

  1. I guess you must mean my comment. Interesting that you didn't answer the question before I attempted to, but waited to see whatever anyone else would answer.

    Its always cheaper in the "cheap seats", that way not only does the view never change, but you never put yourself up for ridicule.

    Just step into the frey, and when you do, tell us all how you use SMA's and EMA's and how you profit$$$ from it.

    Afterall, whether this is a mathematical discussion or a trading discussion, its a discussion. And, most of all, we aren't in college, where one can get credit simply for asking "why". This is the real world, and one has to answer not only why, but "what", as in "what did you do"?
     
    #21     Apr 16, 2002
  2. rrisch/ppoor whatever, you seem to have the answer for your question, so what exactly are you looking for?, and how does it affect the price of tea in China?, IOW, how is it significant towards trading or chart reading?
     
    #22     Apr 16, 2002
  3. That wouldn't be a hint of sacrasm, would it ? Anyway, I'll certainly post the explanation as I promised last night.

    First let's look at a SMA (simple moving average). Let's take a simple example where the prices are: 1 at bar 1, 2 at bar 2, etc.
    Let's calculate a 5 bar SMA. We add the 5 most recent prices and divide by 5, so e.g. the SMA at bar 5 is 3. See the attached picture. Note how the SMA is 2 bars behind the actual data. This is the lag. In general, for a SMA over N elements, the lag is (N-1)/2.

    Now to the exponential MA, which is defined as
    ema(t) = a*Price + (1-a)*ema(t-1);
    You called "a' percent above.

    To calculate the lag for the linear growth (as above) assume that the price is p on this bar. Call the lag L. Then the value of the ema on this bar is (p-L). Insert in the ema formulate above

    (p-L) = a*p + (1-a)*(p-L-1)

    Solve for a to get: a = 1/(L+1)

    To compare to a SMA with lag (n-1)/2 we get a = 2/(n+1)

    That's it. Hope this was helpful.
     
    #23     Apr 16, 2002
  4. forgot picture
     
    • sma.gif
      File size:
      8.4 KB
      Views:
      134
    #24     Apr 16, 2002
  5. rrisch

    rrisch

    Thanks, Vikana. maybe we are making progress. First of all, is the general definition of Lag, Time Series[n] - Moving Average[n]?

    If so, it is clear that the Lag, in general isn't constant. Now I agree with the part that says for the SMA of a linear series with slope 1, Lag = (n -1)/2.

    However I can't make head or tail out of this part:
    (p-L) = a*p + (1-a)*(p-L-1)

    You seem to be saying that your EMA has the property,
    EMA[n - 1] = EMA[n] - 1. Exactly where does that come from?

    I hope you can fill in these details. By the way, isn't there a reference for this? In emails, two well known authors on technical analysis confessed they hadn't the foggiest idea where the 2/(N+1) formula comes from. :confused:
     
    #25     Apr 16, 2002
  6. dottom

    dottom

    An SMA is a Fininte Impulse Response (FIR) filter. The lag, or delay, of any end-to-end symmetric (or anti-symmetric) FIR is approximately one half the filter length. In the case of a time series SMA, the lag of an SMA is exactly (N-1)/2. So a 7-bar SMA has a lag of exactly 3 bars. This lag is referred to as the "group delay" in engineering terms. [Group delay is defined as the rate of change of phase with respect to angular frequency.]

    Regarding the 2/(N+1) for the period in the alpha calculation of an EMA, while I don't know the origin of the formula, the reason the MA is called "exponential" (to answer one of your original questions) is the way an EMA's transfer response decays is in amplitude over N bars. [e.g. The most recent value of the time series is weighted by alpha, the next most recent value is weighted by alpha*(1-alpha), the next value by alpha*(1-alpha)^2 .... the Nth value is weighted by alpha*(1-alpha)^N.]

    Note that for any given period N, the weight of alpha*(1-alpha)^M where M>N, the weighting affect on the MA approaches zero as M increases, hence for practical purposes, the formula of alpha=2/(N+1) generally describes the affect of the EMA weight N periods back.

    The concept of "period" in an EMA is approximate, unlike an SMA or WMA where it is exact. MA's get more interesting when you starting looking at Digital Signal Processing, when you start looking at phase changes. SMA's and WMA's have linear phase lag defined by the fixed period, but EMA's, due to the recursive nature of its calculation, has a nonlinear phase lag.
     
    #26     Apr 16, 2002
  7. Whoa!....Fininte Impulse Response (FIR) filters! Very important point...can't afford to neglect the finite impulse response filters...could really make the difference between making mere thousands and making millions! (STOCKDANCE you reading this??) :)

    Daniel


    (Joking only dottom, this VERY informative stuff)
     
    #27     Apr 16, 2002
  8. tom_p

    tom_p

    The beauty of this forum is that I can selectively steer clear of threads which don't interest me - the thread title being the main indicator. What did you expect to find in a thread entitled "Exponential Moving Average"? Be warned that once we have exhausted the simple, weighted and exponential moving averages, we intend to focus our attention on the properties of the Wilder Moving Average, Least Square Moving Average, Adaptive Moving Average, Endpoint Moving Average, Triangular Moving Average, Sine Weighted Moving Average, Modified Moving Average, MESA Adaptive Moving Average, Elastic Volume Weighted Moving Average, Indicator Adjusted Average and Indicator Weighted Average, not necessarily in that order. :p
     
    #28     Apr 16, 2002
  9. TigerO

    TigerO

    Wow.

    Glad I found this thread, I thought there was a piece missing in the puzzle somewhere.

    Just joking.
     
    #29     Apr 17, 2002
  10. excellent reply, never really knew there were so many ways to draw a line...

    Tommy Rocks!!!
     
    #30     Apr 17, 2002