I am currently working with Ta-lib Java implementations. I can run properly MA & SUM. But having problem while try to run DEMA, TEMA. The output is all zeros. I am calling the DEMA & TEMA method of Ta-lib as follows
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();
}
}
Perhaps the input parameters are not properly set. Please suggest me what I'm doing wrong.
According to the source code of
dema()
,optInTimePeriod
cannot be0
:That's why your current code returns "BadParam" and not "Success" when you call
dema()
.(Same thing goes for
tema()
)