Oanda EMA

Hi all!

I’ve been strugling recently to understand how EMA is calculated. I use Oanda FXTrade, but their calculations never match my - please find mistake:

Let’s use a hypothetical example of the follwoign prices to make it easier:

Hour1 1
Hour2 2
Hour3 3
Hour4 4
Hour5 5
Hour6 6
Hour7 7
Hour8 8
Hour9 9
Hour10 10
Hour11 11
Hour12 12

Now we want to calculate EMA using their formula fxtrade.oanda.com/learn/graphs/overlays/ema.shtml

First we calculate SMA for first EMA_yersterday (SMA(6) for hours 1-6)
SMA(6) = (1+2+3+4+5+6)/6 = 3.5
EMA(1) = alpha * price_hour7 + (1-alpha) * yesterdayEMA = 2/7 * 7 + 5/7 * 3.5 = 4,5
EMA(2) = alpha * price_hour8 + (1-alpha) * yesterdayEMA = 2/7 * 8 + 5/7 * 4.5 = 5.5
EMA(3) = alpha * price_hour9 + (1-alpha) * yesterdayEMA = 2/7 * 9 + 5/7 * 5.5 = 6.5
EMA(4) = alpha * price_hour10 + (1-alpha) * yesterdayEMA = 2/7 * 10 + 5/7 * 6.5 = 7.5
EMA(5) = alpha * price_hour11 + (1-alpha) * yesterdayEMA = 2/7 * 11 + 5/7 * 7.5 = 8.5
EMA(6) = alpha * price_hour12 + (1-alpha) * yesterdayEMA = 2/7 * 12 + 5/7 * 8.5 = 9.5

But when I apply this method to real-time data taken from Oanda in the program I have written it is slighltly different from the Oanda indicators. The difference is quite small 0.0001-0.0002 but at the same time big enough to be introduced by absolute/fractional error or by lost of precision.

What is wrong? Thanks for help

Common, nobody knows how EMA is calculated??

I don’t know if this helps, but this is the formula I use to calculate the EMA:

Current EMA = Previous EMA + (Current Price - Previous EMA) / Time Constant

I try to compare my results to yours, but I don’t know what the variable ALPHA represents in your formula. Maybe you can let me know.

In the meantime, I would contact Oanda to get their formula, then see if there is a slight difference in the way they calculate theirs.

Let me know your thoughts, as I am interested in details as well

MA as calculated based on previous prices. The reason that your MA calculations do not match Oandas is that you are both using different prices. No 2 brokers have the same Open Close High Lows!!! The benefit of the “unregulated market”.

I don’t know what “different” prices you think he’s using, but since he is using FXTrade, the Oanda platform, I think it’s safe to assume that he’s using Oanda’s prices no?

Good point on the different broker’s quotes though, I am amazed at the huge differences at times.

hmm…yes…should have elaborated. Well, the thing is the Fx companies
readjust historical prices at least once a week (courtesy of the unregulated FX market). In Oanda’s case that maybe every day .

Ergo, the prices they dispense to the public is NOT the same as the prices they use for calculations. The difference may very from a 1 pip on every other candlestick to a lot more than just 1 pip.

While unethical, it is not illegal! (Again, courtesy of the unregulated FX market).

Firstly apologies for necro-bumping this thread but since this issue was first posted, the issue still persists.
We are using Oanda’s own data to redraw the EMA. The results derived are off but close. But off nonetheless by at least 1 pips or more. Oanda provides historical prices and so the EMA has to be derived from historical data as the EMA data isn’t provided.

It’s possible to derive calculations of other averages using Oanda’s own data and those numbers (such as SMA or WMA) do match up nicely. Except for the EMA.

Looks like Oanda derives EMA data in some unique way. Does anyone know how? For example how many backlog candles do they use and in what order are the operations carried out (SMA or Close prices) and if there are any offsets used?

Do note that for EMA the period is only used for applying the weight factor. In principal the closing prices used can go back indefinitely. But it’s still not clear what Oanda’s percise method is for deriving the EMA.