【问题标题】:TA-lib: SMA and EMA values are coming out equal for all periodsTA-lib:所有时期的 SMA 和 EMA 值均相等
【发布时间】:2015-10-12 17:51:58
【问题描述】:

当我使用 TA-lib 计算任何时期的 SMA 和 EMA 值时,这些值总是相等的。其他人有这方面的经验吗?谢谢。

Ema 代码(我只是将 Core.Ema 替换为 SMA 的 Core.Sma):

            double[] output = new double[closePrices.Length];
            int begin;
            int length;

            Core.RetCode retCode = Core.Ema(closePrices.Length - 1, closePrices.Length - 1, closePrices, period, out begin, out length, output);

            if (retCode == Core.RetCode.Success)
            {
                for (int i = 0; i < length; i++)
                {
                    result = Math.Round(output[i], 5);
                }
            }

【问题讨论】:

  • 不。它应该工作。请提供代码示例。
  • 嗨 truf。我已将代码添加到我的原始帖子中。谢谢。
  • 如果能获得数据样本来重现问题,那就太好了。你的period 值是多少?如果删除Math.Round,您确定值相等吗?

标签: ta-lib


【解决方案1】:

EMA 方法的起始索引和结束索引是相同的。将起始索引更改为 0。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 2018-10-25
    • 2015-03-22
    • 2020-06-14
    • 2017-03-09
    • 1970-01-01
    • 2017-09-09
    相关资源
    最近更新 更多