Hello,
I'm new to JForex and I'm not quite sure if this is a bug or I'm simply missing some step in making my strategy work. The problem is that when I start a strategy and try to add an indicator, the chart object is null. Here is what I do...
First I connect and then subscribe to an instrument and start the strategy with this code:
...
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.EURUSD);
client.setSubscribedInstruments(instruments);
client.startStrategy(new MyStrategy());
In the strategy class
MyStrategy in the method
onStart I have put this code:
indicators = context.getIndicators();
IChart chart = context.getChart(Instrument.EURUSD);
chart.addIndicator(indicators.getIndicator("STOCH"));
The problem is that
chart is null and when trying to add the indicator an exception is thrown. I have searched for a solution for this problem, but I didn't find anything. Moreover, all examples that I found do it in this way. Is there a need to add this chart somehow before getting it from the context? I tried to find a way to add a chart but I didn't came upon an appropriate method. Or I may miss something else?
Please help and thank you in advance!