# What is the minimum history data size to get an accurate EMA/ MACD for latest history point

Currently, I have history data for 10 years.

Most of the time, I only interested in getting EMA/ MACD for the last history point (means yesterday point). Instead of using entire 10 years history, I would only like to provide N data points, for fast calculation, yet get a reasonable accurate EMA. Currently, here is the way for me to determine how many N data.

9 days SMA lookback = 8
9 days EMA lookback = 8
9 days 12/26 MACD lookback = 33

final int scale = 2;
startIndex = historyDataSize - ((lookback + 1) * scale);
for (int i = startIndex; i < historyDataSize; i++) {
// ...
}


I know I can further increase scale to get a reasonable good EMA/ MACD outcome. The question is, how large I should increase, for fast calculation purpose, yet reasonable accurate?

-

You shouldn't recompute your EMA - just keep its old values, and apply your EMA formula to the last value to update.

-
They are asking how many data points to start with. 1 bar? 10 bars? 100 bars? –  Chloe Apr 5 '12 at 3:12
"I would only like to provide N data points, for fast calculation.." - my point is that the number of points shouldn't affect the speed: use all the data you have, run EMA on it once (go have a drink while the data is being processed), and once it's done, you only have to update the last value –  LazyCat Apr 5 '12 at 15:42