我目前正在使用Ta-lib Java实施。我可以正常运行MA&和。但是在尝试运行DEMA,TEMA时遇到问题。输出全为零。 我打电话给DEMA& Ta-lib的TEMA方法如下
import com.tictactec.ta.lib.Core;
import com.tictactec.ta.lib.MInteger;
public class TALibJava {
double[] array = {207.650, 205.160, 210.870, 209.350, 207.250, 209.960, 207.650, 205.160, 188.170, 186.020};
double[] output = new double[array.length];
int period = 5;
Core core = new Core();
int lookback = 0;
MInteger begin = new MInteger();
MInteger length = new MInteger();
public void callDEMA() {
lookback = core.demaLookback(period);
core.dema(0, array.length - 1, array, 0, begin, length, output);
System.out.println("DEMA Output: ");
print();
}
public void callTEMA() {
lookback = core.temaLookback(period);
core.tema(0, array.length - 1, array, 0, begin, length, output);
System.out.println("TEMA Output: ");
print();
}
public void print() {
for(int i=0;i<array.length;i++) {
System.out.print(output[i] + "\t ");
}
System.out.println("");
}
public static void main(String args[]) {
TALibJava obj = new TALibJava();
obj.callDEMA();
obj.callTEMA();
}
}
可能未正确设置输入参数。请告诉我我做错了什么。
答案 0 :(得分:1)
根据source code of dema()
,optInTimePeriod
不能是0
:
else if( ((int)optInTimePeriod < 2) || ((int)optInTimePeriod > 100000) )
return RetCode.BadParam ;
当你拨打dema()
时,这就是你当前代码返回“BadParam”而不是“Success”的原因。
(同样适用于tema()
)