到目前为止,我一直在使用这个公式(在下面的文档第10页),计算简单的指数移动平均线:
http://www.eckner.com/papers/Algorithms%20for%20Unevenly%20Spaced%20Time%20Series.pdf
time_interval =(now - last_update)/ tau
w = exp(-time_interval)
w2 =(1 - w)/ time_interval
new_ema = old_ema * w + current_value *(1 - w2)+ previous_value *(w2 - w)
(此方法的好处是,如果时间间隔很长,则假定值从previous_value线性变化为current_value。)
如果我要将此方法扩展为双指数平滑,我该怎么做?
标准双EMA:
dema_new = dema_old * alpha +(current_value + previous_trend)*(1-alpha)
current_trend = old_trend * beta +(dema_new - dema_old)*(1-beta)