I'm testing indicators with periods other than the selected chart timeframe. As input I'm passing bars with the timeframe being passed by an optional parameter.
I now experience that calculate is being called with endIndex > inputs.length when adding the indicator to a chart.
The error even shows up when setting the optional period parameter to the same value as the selected period on the chart.
The start of calculate reads as follows:
public IndicatorResult calculate(int startIndex, int endIndex) {
//calculating startIndex taking into account lookback value
if (startIndex - getLookback() < 0) {
startIndex -= startIndex - getLookback();
}
if (startIndex >= endIndex || inputs[0].length < endIndex) {
context.getConsole().getOut().println("Testindicator.log: index/inputs-arraysize problem: startIdx/endIdx=" + startIndex + "/" + endIndex + ", inputs.length=" + inputs[0].length);
return new IndicatorResult(0, 0);
}
....
The indicator is producing the following log messages. You can see, that the DukasCopy error message states that the input array size = 4000, which it clearly isn't (length=142...).
Quote:
11:44:58 Error in indicator: calculate() method of indicator [TestIndicator] returned less values than expected. Requested from-to [0]-[3999], input array size [4000], returned first calculated index [0], number of calculated values [0], lookback [0], lookforward [0], expected number of elements is [4000]
11:44:58 TestIndicator.log: index/inputarray problem: startIdx/endIdx=0/3999, inputs.length=142
I've attached the test code.
I guess this a bug?
Or am I missing something here?
Any feedback is highly appreciated.
Thanks & best, RR.