TradingView Script. Free TradingView account required to use. Direct link: https://www.tradingview.com/script/NwvUwIQ3-Demonstration-of-how-history-length-affects-all-EMA-values/
I saw some discussion of this so I whipped up an example to prove the that effect of history length on EMA values is pronounced, even for bars much further than the EMA length away from the first candle of the chart.
This chart has two 89-bar EMAs of the close: a green one and a red one. However, for the red one, the first 89 bars of the graph are considered to have a close of “0”, which is exactly whatTradingView’s EMA calculation uses for bars before the start of the graph.
This is because unlike other moving averages, which reference the price of previous bars, the EMA references the EMA of previous bars. Therefore, bars closer to the beginning of the chart, where TradingView can’t calculate an EMA because there is no previous EMA and therefore uses 0, will return substantially different values for the EMA () function that the same cart would with more history.
The further a bar is back in history, the less influence it has. However, every single historical bar has some influence on the EMA of every later bar.
To allow you to see this for yourself, this script contains the following inputs which you can change to see the effect:
-EMA period (default 89)
-Number of bars to ignore for EMA2 (default 89)
-decimal precision to show differences in. By making this a large number you can see that, although the effects diminish, history length affects all EMA values for the char.
-label spacing (increase this if you have a long history and run into TV’s 50-label limit)