Download MetaTrader 5
To add comments, please log in or register
Write articles, help other developers and make money
Harsh Lath
7
Harsh Lath 2015.09.09 12:13 

Hello,

 

I need to calculate EMA in excel for backtesting. The formula for MT4 help topics is:

EMA = (CLOSE(i) * P) + (EMA(i - 1) * (100 - P))

 Where:

CLOSE(i) — the price of the current period closure;
EMA(i-1) — Exponentially Moving Average of the previous period closure;

P — the percentage of using the price value. 

Question:

a) Does anyone what value MT4 assigns to 'P'

b) Also I need Previous period EMA. How do I get that for my starting point

 

Thanks a lot 

whroeder1
13597
whroeder1 2015.09.09 13:10  
harshlath: EMA = (CLOSE(i) * P) + (EMA(i - 1) * (100 - P))
  1. This is the same as in Moving average - Wikipedia, the free encyclopedia except it's not 100 - P but 1 - Alpha.
  2. Don't use that formula as in magnifies roundoff. Use the rewritten version that that fades roundoff. EMA = EMA(i-1) + alpha * [Close(1) - EMA(i-1)]
  3. In any case, alpha = 2 / (period + 1) and your P = 100 * alpha. Drop P and just use alpha.
  4. Starting point is irrelevant and arbitrary. use first close or average of the first few. You must have 3.45 (N+1) bars from the first before your EMA is relevant from any starting point.
/
To add comments, please log in or register