Mean value algorithm of MA, EMA, SMA, DMA, TMA, WMA6

Source: Internet
Author: User

Mean value algorithm of MA, EMA, SMA, DMA, TMA, WMA6

MA, EMA, SMA, DMA, TMA, WMA6 average algorithms are often used in various indicator formulas, but most beginners may not understand their specific differences, organized as follows.

MA (x,n) simple arithmetic average
The N-day moving average of x, not the weight, the average calculation. The algorithm is:
(X1+X2+X3+.....+XN)/n
For example, MA (c,20) represents the average closing price of 20th. C means close.

EMA (x,n) exponential smoothed moving average
The N-day exponential smoothed moving average of X, its true formula expression is: the day exponential average = smoothing factor * (Day index value-yesterday index average) + yesterday's index average, smoothing coefficient =2/(period unit +1), deduced from the above formula, obtained: EMA (c,n) =2*c/(n+1) + ( N-1)/(n+1) * Average of yesterday's index close;
The algorithm is: if Y=ema (x,n), then y=[2*x+ (N-1) *y ']/(n+1), where Y ' represents the Y value of the previous period.
The EMA reference function is easy to implement using recursive algorithms on the computer, but it is not easy to understand. An example of an analysis illustrates the EMA function.

X is a variable, each day the x values are different, from far to near the mark, they are recorded as X1,x2,x3,....,xn
If n=1, then EMA (x,1) =[2*x1+ (1-1) *y ']/(+) =x1
If n=2, then EMA (x,2) =[2*x2+ (2-1) *y ']/(2+1) = (2/3) *x2+ (1/3) X1
If n=3, then EMA (x,3) =[2*x3+ (3-1) *y ']/(3+1) =[2*x3+2* ((2/3) *x2+ (1/3) *x1)]/4= (a) *x3+ (1/3) *x2+ (1/6) *x1
If n=4, then EMA (x,4) =[2*x4+ (4-1) *y ']/(4+1) =2/5*x4+3/5* ((a) *x3+ (1/3) *x2+ (1/6) *x1)
=2/5*x4+3/10*x3+1/5*x2+1/10*x1
If n=5, then EMA (x,5) =2/(5+1) *x5+ (5-1)/(5+1) (2/5*X4+3/10*X3+3/15*X2+3/30*X1)
= (1/3) *x5+ (4/15) *x4+ (3/15) *x3+ (2/15) *x2+ (1/15) *x1
............ Cycle

X1
(2/3) *x2+ (1/3) X1
(3/6) *x3+ (2/6) *x2+ (1/6) *x1
(4/10) *x4+ (3/10) *x3+ (2/10) *x2+ (1/10) *x1
(5/15) *x5+ (4/15) *x4+ (3/15) *x3+ (2/15) *x2+ (1/15) *x1

At any time the sum of the coefficients is 1. If x is constant, the daily x value is unchanged, then EMA (x,n) =ma (x,n).

From the above example, we can see that the closer the time period of the X value of its weight is greater, indicating that the EMA function on the recent X-value to strengthen the weight ratio, more timely to reflect the recent X-value fluctuations. Therefore, EMA is more valuable than MA, and EMA is not prone to die forks and gold forks, so once appear to reflect immediately! The EMA is more stable on the weekly line.

After understanding the meaning of Ma,ema, we can understand its use, simply said, when we want to compare the value and the average price of the relationship, with the MA can be, and to compare the trend of the average speed, with EMA more stable; sometimes, when the value is not important, also use EMA to smooth and beautiful curve.

SMA (c,n,m) Moving average
After understanding the meaning and use of the MA and EMA, the following functions are well understood, since the EMA's smoothing coefficient is fixed, =2/(period + 1); What if we want to change the smoothing coefficients? This uses the SMA, and the difference between the EMA is to increase the weight of the parameter m, that is, using m instead of the EMA smoothing coefficient of 2, so that we can adjust the value of the day in the average price of the weight =m/n. (Request N>m)

DMA (c,a) dynamic moving average
Note that the weight coefficients in the EMA and SMA are both numerical and periodic calculation of decimals, assuming that a decimal can directly represent the weight, how to do? This has the DMA,DMA (C,a) A is the weight value, the formula is as follows: X=DMA (c,a) =a*x+ (1-a) *x ' (A less than 1), you can find that the DMA and SMA principle is one, just a decimal place directly instead of m/n, and in the practical, This decimal value is the most valuable is the turnover rate =V/CAPITAL;DMA (c,v/capital) The direct meaning is to use the turnover rate as a weighting factor, using the same day close in the average price of the share to calculate the average, intuitive understanding is the greater the rate of change, the closing price in the average value of the greater the role!

TMA (x,n,m) recursive moving average
Usage: TMA (X,N,M), the recursive moving average of x, N, M is weighted. Algorithm: If Y=tma (x,n,m) is y= (N*y ' +m*x), where Y ' represents the previous period Y value. The initial value is m*x.
For example: TMA (close,0.9,0.1) means that the recursive moving average of x is calculated

WMA (x,a) weighted moving average
Usage: WMA (X,A), for the weighted moving average of x. Algorithm: If Y=wma (x,a), then y= (n*x0+ (n-1) *x1+ (n-2) *x2)/(+...+1*XN (n+) + (n-1) n-2) +...+1 represents the current period value, and x0 represents the previous period value.

The mean formula has been used in many index formulas, and a thorough understanding of the meanings of the above-mentioned mean values is the precondition of rational application of various index formulae.
Original link: http://www.55188.com/viewthread.php?tid=3613363

Mean value algorithm of MA, EMA, SMA, DMA, TMA, WMA6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.