For example, on a 15min bar (bar A) right after the close of bar A I read the 200 SMA and 200 EMA at 45.90 and 45.99 respectively. Then a few hours later I go back to that exact same bar (bar A), but the SMA and EMA have changed and are no longer the 45.09 and 45.99. I do not understand why this is. I thought once the value was calculated for the 200 EMA and 200 SMA at that specific time point, that would always be the value at that specific time point. Then as time went on more calculations would be made to continue the curve of the EMA and SMA, but the value for the SMA and EMA on bar A would remain constant.

Is there something wrong with my charts (IB)? Or, am I missing something? I get that the most distant value is dropped out of the calculation as another time interval is added to the moving average, but I do not see how this would affect the value of the SMA and EMA on bar A. This makes it hard to back test a strategy by just scrolling through the chart since the EMA and SMA are a different value when compared to the value when they were first calculated.

IB= interactive broker EMA= exponential moving average SMA= simple moving average


The moving average at a fixed point in time should always be the same, at any point in time that is one tick different, which may be under a millisecond if there are high frequency traders trading, it will be different as it will capture a different set of values. I don't know the IB system but if you can set the time to an exact number rather than scrolling by hand an eye then the data points should be identical. If they are not identical at identical times then there is a bug which you should report. For back testing you will probably want to download the data set and calculate the moving average per tick so that you can run simulations on that basis and instantaneously (or nearly instantaneously) get the MA value.

Note that these will be large datasets which contraindicate the use of Excel. In my line of work we tend to use SAS, Python or R. An additional benefit will be the ability to automate your backtesting in these languages.

  • MD-Tech thanks for the response. That is what i thought. Thanks. It definitely happens when i scroll through the chart. I will have an EMA with a value of X then i scroll through the chart several days and see the EMA generate on the new chart position, then i go back to the orginial chart position and the EMA is different. Additionally, When i exited out last night i wrote down some EMAs and this morning the EMAs were different, however, i did not have to change the chart position this time. So it seems the EMA changes as time goes on regardless of if i scroll or not. I will contact IB. – acqualife Oct 26 '16 at 16:15
  • EMA should change as time goes on; it is a moving average over a time period not a simple average AND new data is exponentially more highly weighted than the last data point. – MD-Tech Oct 26 '16 at 16:22
  • Okay so i am now confused. What i am saying is the EMA at time A is X then as time moves on i go back to time A and the EMA is not the value X. Or EMA at time A is value X as i scroll backwards in the chart and then go back to time A EMA is not value X. This is also true for SMA. I just talked to IB and they said this is not correct. So, are they right? EMA at time A should always be value X? I know as time goes on the current value of EMA changes, but the value at time A should always be X. Correct? Thank you very much for your help. I greatly appreciate it! – acqualife Oct 26 '16 at 16:47
  • Can you please tell me the exact question that you asked them. – MD-Tech Oct 26 '16 at 16:58
  • interactivebrokers.co.uk/en/software/tws/usersguidebook/… according to their website they are wrong. Incidentally how much are their numbers out by? – MD-Tech Oct 26 '16 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.