Because iMA and iMAOnArray are two different functions.
I understand that. I am trying to calculate EMA for the same values with iMA and iMAOnArray, but i get different result
I understand that. I am trying to calculate EMA for the same values with iMA and iMAOnArray, but i get different result
What is the amount of the difference?
An EMA is affected by every single price in the history (albeit by increasingly tiny amounts), not just the period such as 12 bars. Therefore, a calculation using iMA(), with e.g. 10,000 bars in the available history, will give a slightly different answer to iMAOnArray(), with e.g. 1,000 bars in the array.
... but only usually by a tiny amount.
Try to use MovingAverages.mqh
What is this?
What is the amount of the difference?
An EMA is affected by every single price in the history (albeit by increasingly tiny amounts), not just the period such as 12 bars. Therefore, a calculation using iMA(), with e.g. 10,000 bars in the available history, will give a slightly different answer to iMAOnArray(), with e.g. 1,000 bars in the array.
... but only usually by a tiny amount.
Ah it makes sense then. However I still do not see why iMAOnArray is different from my excel calculations, I think I am using correct formula.... Anybody?...
Ah it makes sense then. However I still do not see why iMAOnArray is different from my excel calculations, I think I am using correct formula.... Anybody?...
Your Excel calculation looks correct, and I get the same result - 1.2891614 - if I read that list of prices into an array and then do iMAOnArray() on it.
Sorry, where did you get that number from?.. I am getting different numbers, I don't get 1.2891614 anywhere
set the array as series before filling
I tried filling array from both sides (as far as I understand its the same as setting as series or not series) and still not getting number as in my excel...
Sorry, where did you get that number from?.. I am getting different numbers, I don't get 1.2891614 anywhere
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I am quite new to MQL and trying to create my first EA and I got some strategy where I need to calculate EMA. I am working on 15m period, EUR/USD, calculating on close prices. I got sheet with historic prices where I calculated EMA myself. However the result is different from what i get with MQL
When doing iMAOnArray(arr, 0, 12, 0, MODE_EMA, 0) on these prices I get final EMA = 1.276702082774568 or 1.276246812078973 if set as series.
When I am geting EMA with
EMA is equal = 1.276701681147687
While in my excel I calculated EMA as 1.276706828
I believe my excel is correct. Why do I have different EMAs with iMAOnArray and iMA and my excel? Anybody could help? Struggling with this for 3 days already......
void OnTick()
{
if (TimeHour(TimeCurrent()) == 8 && TimeMinute(TimeCurrent()) == 45) //to get ema for 8:30 close price. (date is correct)}
}
Cannot attach excel file here, so uploaded it here - https://ufile.io/acada
For quick view this is the table of my prices:
Date (2010y) Close price EMA 12