Hi everybody,
I tried to change a bit the example code of the indicator in Wiki in this way:
private Period period = Period.DAILY;
public void onStart(IIndicatorContext context) {
indicatorInfo = new IndicatorInfo("EXAMPIND", "Sums previous values", "My indicators",false, false, false, 1, 1, 1);
inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("Input data", InputParameterInfo.Type.DOUBLE)};
inputParameterInfos[0].setPeriod(this.period);
optInputParameterInfos = new OptInputParameterInfo[] {new OptInputParameterInfo("Time period", OptInputParameterInfo.Type.OTHER,new IntegerRangeDescription(2, 2, 100, 1))};
outputParameterInfos = new OutputParameterInfo[] {new OutputParameterInfo("out", OutputParameterInfo.Type.DOUBLE,OutputParameterInfo.DrawingStyle.LINE)};
}
(I did that because I'd like to create an indicator which is independent from the chart timeframe)
But I get an exception in the calculate method:
20:01:27 Error in indicator: java.lang.ArrayIndexOutOfBoundsException: 1 @ jforex.Indicator.calculate(Indicator.java:36)
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[1][i - k];////Line 36 throwing the exception
}
outputs[0][j] = value;
}
return new IndicatorResult(startIndex, j);
}
I'm quite new to java, so, sorry if it's a stupid question.
Thank you in advance,
Calogero