Moving average changing value as time move along
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
1 Comments
Sorted by latest first Latest Oldest Best
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.
Terms of Use Privacy policy Contact About Cancellation policy © freshhoot.com2026 All Rights reserved.