The only thing I can provide is the message that it prints out (I hope that this is the stack trace, otherwise I have no clue what a stack trace is):
Quote:
Error in indicator: java.lang.IllegalArgumentException: java.lang.ClassCastException@1509a03 @ com.dukascopy.indicators.BOLLB.calculate(BOLLB.java:51)
The full code is below:
package com.dukascopy.indicators;
import com.dukascopy.api.indicators.*;
public class BOLLB implements IIndicator {
private IndicatorInfo indicatorInfo;
private InputParameterInfo[] inputParameterInfos;
private OptInputParameterInfo[] optInputParameterInfos;
private OutputParameterInfo[] outputParameterInfos;
private double[][] inputs = new double[1][];
private double[][] outputs = new double[1][];
private int timePeriod = 10;
private double deviation = 1.5;
private IIndicator bbands;
public void onStart(IIndicatorContext context) {
bbands = context.getIndicatorsProvider().getIndicator("BBANDS");
indicatorInfo = new IndicatorInfo("BOLLB", "Bollinger's %b", "My indicators",
false, false, false, 1, 0, 1);
inputParameterInfos = new InputParameterInfo[] {new InputParameterInfo("In", InputParameterInfo.Type.DOUBLE)};
outputParameterInfos = new OutputParameterInfo[] {new OutputParameterInfo("%b", OutputParameterInfo.Type.DOUBLE,
OutputParameterInfo.DrawingStyle.LINE)};
}
public IndicatorResult calculate(int startIndex, int endIndex) {
if (startIndex - getLookback() < 0) {
startIndex -= startIndex - getLookback();
}
if (startIndex > endIndex) {
return new IndicatorResult(0, 0);
}
bbands.setInputParameter(0, inputs[0]);
bbands.setOptInputParameter(0, timePeriod);
bbands.setOptInputParameter(1, deviation);
bbands.setOptInputParameter(2, deviation);
double[] upperBB = new double[endIndex + 1 - bbands.getLookback()];
double[] middleBB = new double[endIndex + 1 - bbands.getLookback()];
double[] lowerBB = new double[endIndex + 1 - bbands.getLookback()];
bbands.setOutputParameter(0, upperBB);
bbands.setOutputParameter(1, middleBB);
bbands.setOutputParameter(2, lowerBB);
IndicatorResult dbbandsResult = bbands.calculate(startIndex, endIndex);
int i, k;
for (i = 0, k = dbbandsResult.getNumberOfElements(); i < k; i++) {
outputs[0][i] = (inputs[0][i] - lowerBB[i]) / (upperBB[i] - lowerBB[i]);
}
return new IndicatorResult(startIndex, i);
}
public IndicatorInfo getIndicatorInfo() {
return indicatorInfo;
}
public InputParameterInfo getInputParameterInfo(int index) {
if (index <= inputParameterInfos.length) {
return inputParameterInfos[index];
}
return null;
}
public int getLookback() {
return bbands.getLookback();
}
public int getLookforward() {
return 0;
}
public OptInputParameterInfo getOptInputParameterInfo(int index) {
if (index <= optInputParameterInfos.length) {
return optInputParameterInfos[index];
}
return null;
}
public OutputParameterInfo getOutputParameterInfo(int index) {
if (index <= outputParameterInfos.length) {
return outputParameterInfos[index];
}
return null;
}
public void setInputParameter(int index, Object array) {
inputs[index] = (double[]) array;
}
public void setOptInputParameter(int index, Object value) {
}
public void setOutputParameter(int index, Object array) {
outputs[index] = (double[]) array;
}
}
According to the ta-lib source the bbands function header is:
public RetCode bbands( int startIdx,
int endIdx,
double inReal[],
int optInTimePeriod,
double optInNbDevUp,
double optInNbDevDn,
MAType optInMAType,
MInteger outBegIdx,
MInteger outNBElement,
double outRealUpperBand[],
double outRealMiddleBand[],
double outRealLowerBand[] )