• 0

# How is EMA50 and EMA200 being calculated on the charts as it looks non-standard?

## Question

I downloaded historical data from the US 500 via the API. I verified that the 320 data points I downloaded match the UI on the graph. When I calculate the EMA50 and EMA200 on my dataset correctly I get a different result to what is shown on the IG charts. I thought it may a precision difference that could cause the small difference I'm seeing but I checked that and that looks okay to me. I checked my dataset and it's clean without missing data.

I'm doing my calculation in Python as follows:

# Apply the exponential moving averages

Just for interest sake I checked the SMA50 and SMA200 and they are an exact match.

There is something strange about the EMA calculation on the charts. Does anyone know what it is?

## Recommended Posts

• 0
Posted (edited)

Hi mgwuk

Glad you posed this question as I have been trying for the last number of weeks to ask the same question of IG and am still waiting on a response. Did you come up with an answer?

My workings below on how to calculate EMA clearly does not match IG Chart using IG data and EMA indicator and the method provided by IG which can be calculated as follows for example for EMA21:

where:
k = smoothing parameter which is 2/(lookback period+1) or for EMA21 is 2/(21+1) = 0.0909091
EMAt = previous candle EMA21 value

Both formulae below result in same value
EMA21 = k * close price + (1-k) * EMAt
or
EMA21 = EMAt + k *(close price-EMAt)

The following values in blue are taken from the 5 minute interval Nikkei 225 Japan Cash from IG charts looking at EMA21.

You can see from the table below the difference in calculated values using the above formula versus the IG chart data.

 Sydney Time Close Price calc_EMA21 IGchart_EMA21 11/04/2024 1:25 39282.2 11/04/2024 1:30 39252.2 11/04/2024 1:35 39192.2 11/04/2024 1:40 39167.2 11/04/2024 1:45 39172.2

Obviously, the chart data is using a different formula. The SMA values align perfectly as you found.

Edited by Bliz_23

## Create an account

Register a new account