Hi I am trying to subscribe to 4 pairs on my strategy ..everything complies ok but it had error when running
code is as follows
public void onStart(IContext context) throws JFException {
this.console = context.getConsole();
this.indicators = context.getIndicators();
this.history = context.getHistory();
this.engine = context.getEngine();
this.account = context.getAccount();
this.context = context;
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.EURUSD);
instruments.add(Instrument.EURCAD);
instruments.add(Instrument.USDSGD);
instruments.add(Instrument.GBPUSD);
context.setSubscribedInstruments(instruments);
if (appliedPrice.equals(AppliedPrice.OPEN)) {
appliedPriceParam = 0;
} else if (appliedPrice.equals(AppliedPrice.CLOSE)) {
appliedPriceParam = 1;
} else if (appliedPrice.equals(AppliedPrice.HIGH)) {
appliedPriceParam = 2;
} else if (appliedPrice.equals(AppliedPrice.LOW)) {
appliedPriceParam = 3;
}
feedDescriptor = new FeedDescriptor();
feedDescriptor.setDataType(DataType.RENKO);
feedDescriptor.setOfferSide(offerSide);
feedDescriptor.setInstrument(instrument);
feedDescriptor.setPriceRange(PriceRange.valueOf(priceRangePips));
feedDescriptor.setFilter(filter);
IChart chart = context.getChart(instrument);
if (chart != null) {
chart.addIndicator(indicators.getIndicator("JAMES_INDI"), new Object[]{appliedPriceParam });
}
context.subscribeToRenkoBarFeed(instrument, offerSide, PriceRange.valueOf(priceRangePips), this);
and I get the following error when running
2012-07-23 00:00:00 Exception java.lang.IllegalArgumentException: Could not load data for Instrument=null because this Instrument isn't subscribed! @ jforex.strategies.indicators.tradebynumbers.onStart(tradebynumbers.java:102)