寻找一种使用Esper(EPL)语句在5个EMA5和EMA20的窗口上计算指数移动平均线的方法。

我传入了priceEvent(timeStamp,符号和价格)流,并在滑动窗口5上编写了一个简单的移动平均SMA。但是,对于Esper来说还很陌生,他正在寻找一种在滑动窗口上计算指数移动平均线(EMA)的方法。

http://www.iexplain.org/ema-how-to-calculate/

如果有人可以帮助我编写抛物线合成孔径雷达函数,那也会有很大帮助

最佳答案

好的,我做了很多学习和研究,以找到找到指数移动平均值的解决方案,以下是有助于计算ema5的EPL语句

//create a named window EMA5 Window
create window EMA5Window.win:length(1) as select price as ema5 from Quote

//insert the mean of first 5 events
insert into EMA5Window select Avg(price) as ema5 from Quote.win:firstlength(5)

//after 5 events calculate todays ema = (today's price)/3 +  (yesterday's ema)*2/3, refer to http://www.iexplain.org/ema-how-to-calculate/ for ema formula

insert into EMA5Window select ((price)*(1/3)+(2/3)*(select ema5 from EMA5Window)) as ema5 from Quote output after 5 events

// now select the ema5 as below
select ema5 as ema5 from EMA5Window output after 5 events


一旦完成,计算抛物线SAR的工作将更新。
谢谢

09-13 12:24