C#Ta-Lib指数移动平均值(EMA)计算 [英] C# Ta-Lib Exponential Moving average(EMA) calculation

查看:930
本文介绍了C#Ta-Lib指数移动平均值(EMA)计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#项目中使用Ta-lib库来计算指数移动平均值.我必须计算20个周期的EMA.我在电子表格(Excel)上进行了计算,得到了正确的结果;在ta-lib库中使用相同的数据点时,我得到了错误的结果.

I am using the Ta-lib library in my C# project to calculate Exponential moving averages. I have to calculate EMA for 20 periods. I did my calculation on a spreadsheet (Excel) and I got the correct result; while using the same data points with ta-lib library I am getting wrong result.

我正在使用所附图片中的收盘价.

I am using close price from the attached image.

Core.Ema(startIdx, endIdx, close, 20, out outBegIdx, out outNBElement, smoothClose);

运行ta-lib函数后,我的结果是

after running ta-lib function my result is

113.783380952381
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

在Excel中以相同的周期值运行EMA公式时,我的结果在所附的图片中被提及

While running the EMA formula on Excel with same period values my result is mentioned in attached image

推荐答案

另一个注意事项是您的数据顺序是相反的.日期在您的数组中应升序,最新的日期是最后一个条目,最早的日期是第一个条目

One other note is that your data order is reversed. The dates should be ascending in your array with the latest date being the last entry and the earliest date being the first entry

这篇关于C#Ta-Lib指数移动平均值(EMA)计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆