Hi, I have read JForex Wiki article:
https://www.dukascopy.com/wiki/#Add_indicators_on_chartand trying to add STOCH indicators on chart with optional field but getting following exceptions.
Can you please help me out what is expected option values for STOCH?
It would be nice if exception can includes expected option values.
Caused by: java.lang.IllegalArgumentException: Unexpected optional parameter [com.dukascopy.api.IIndicators$MaType]=[EMA] for index [2]
at com.dukascopy.charts.math.dataprovider.AbstractDataProvider.initIndicatorInputs(AbstractDataProvider.java:548)
at com.dukascopy.charts.math.dataprovider.AbstractDataProvider.addIndicator(AbstractDataProvider.java:410)
at com.dukascopy.charts.data.AbstractDataSequenceProvider.addIndicator(AbstractDataSequenceProvider.java:497)
at com.dukascopy.charts.chartbuilder.DataManagerImpl.addIndicator(DataManagerImpl.java:74)
Here is my code:
@Configurable("FastKPeriod")
public int fastKPeriod = 8;
@Configurable("SlowKPeriod")
public int slowKPeriod = 3;
@Configurable("MAType")
public MaType mAType = MaType.EMA;
public void onStart(IContext context) throws JFException {
this.context = context;
this.engine = context.getEngine();
this.indicators = context.getIndicators();
this.console = context.getConsole();
this.history = context.getHistory();
Set<Instrument> subscribedInstruments = context.getSubscribedInstruments();
if (!subscribedInstruments.contains(this.instrument)) {
subscribedInstruments.add(this.instrument);
}
context.setSubscribedInstruments(subscribedInstruments);
IChart chart = context.getChart(this.instrument);
IIndicator indSTOCH = indicators.getIndicator("STOCH");
for (int i = 0; i < indSTOCH.getIndicatorInfo().getNumberOfInputs(); i++) {
InputParameterInfo inputParameterInfo = indSTOCH.getInputParameterInfo(i);
inputParameterInfo.setOfferSide(side);
inputParameterInfo.setAppliedPrice(IIndicators.AppliedPrice.CLOSE);
}
chart.addIndicator(indicators.getIndicator("STOCH"), new Object[] { fastKPeriod, slowKPeriod, mAType, slowDPeriod, mAType});
chart.addIndicator(indicators.getIndicator("RSI"), new Object[] { rsiPeriod});
}