我从TA-LIB妈妈指标中得到了奇怪的结果。
使用相同价格数组调用其他指标会得出正确的结果。
但是调用core.mama()
会使Mama值增加1点或2点,而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)
返回的值更长的回溯才能获得有意义的结果。因此,您需要传递足够长的价格数组。
我现在得到可靠的结果。