1

我从 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;
    }
}
4

1 回答 1

2

好的 - 我的错

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

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

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

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

于 2016-02-09T15:26:14.813 回答