gpt4 book ai didi

java - TA-LIB Mama 指示器的结果不正确

转载 作者:行者123 更新时间:2023-11-30 03:04:10 24 4
gpt4 key购买 nike

我从 TA-LIB Mama 指标中得到了奇怪的结果。

使用相同价格数组调用其他指标会给出正确的结果。

但是调用 core.mama() 可以让 Mama 的值增加一到两个点,而 Fama 的值最多增加 30 个点。我正在与 JForex 中的值进行比较,我已针对其他平台验证了该值。

我通过调用 TA-LIB 来设置价格数组的长度,但较长的回溯并不能改善结果:

int priceLength = core.mamaLookback(fastLimit, slowLimit) + 1;

我的 fastLimit 和 SlowLimit 设置在合理的范围内。

startIdx 参数更改为 0 并返回更多值也没有帮助。

代码非常简单,很难看出我可能做错了什么。是我脑子有问题,还是图书馆被窃听了?

   public static double[] runMama(double[] prices, double fastLimit, double slowLimit) {

try {
MInteger outBegIdx = new MInteger();
MInteger outNbElement = new MInteger();
int count = prices.length;
Core core = new Core();

// We only need the most recent value.

double[] outputFama = new double[1];
double[] outputMama = new double[1];

RetCode retCode = core.mama(count-1, count-1, prices, fastLimit, slowLimit, outBegIdx, outNbElement, outputMama, outputFama);

if (retCode != RetCode.Success) {
throw new RuntimeException("TA-LIB Mama has barfed!");
}

return new double[]{outputMama[0], outputFama[0]};

} catch (Exception e) {
Printer.printErr("Problem with MESA", e);
return null;
}
}

最佳答案

好吧——我的错

我没有意识到 Java TA-Lib 以一种有点奇怪的方式返回数据。

与几乎所有其他交易库相比,最新值具有更高的键,最高的键被填充了许多与回溯长度相关的零值。

此外,当指标具有内存功能时(例如基于指数 MA 的 Mama),您需要比 core.mamaLookback(fastLimit, slowLimit) 返回的值更长的回溯时间。以获得有意义的结果。所以你需要传入一个足够长的价格数组。

我现在得到了可靠的结果。

关于java - TA-LIB Mama 指示器的结果不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35202839/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com