Hello, I', just starting with jforex. When I try to make a simple SMA and print in the chart I must shift with -1 value to get adjust to native SMA. What am I doing wrong ?
public IndicatorResult calculate(int startIndex, int endIndex) {
//calculating startIndex taking into account lookback value
if (startIndex - getLookback() < 0) {
startIndex -= startIndex - getLookback();
}
int i, j;
for (i = startIndex, j = 0; i <= endIndex; i++, j++) {
double value = 0;
for (int k = timePeriod; k > 0; k--) {
value += inputs[0][i - k];
}
outputs[0][j] = value/timePeriod;
}
return new IndicatorResult(startIndex, j);
}
MySMA is green and native is blue.
Thanks