Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

chart error on strategy start
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=57120
Page 1 of 1

Author:  ronaldexim [ Sat 27 Jul, 2019, 14:36 ]
Post subject:  chart error on strategy start

I get active chart instrument with
context.getLastActiveChart().getInstrument();

But if I fresh start JForex platform and run strategy has got error (java.lang.IllegalStateException: Chart is closed).
If I first click on chart, strategy starts without error.

I try without success:
currChart = context.getLastActiveChart();
if (currChart.equals(null)) {
   currChart = context.getChart(Instrument.USDJPY);
}

How can I avoid this error?

Author:  API Support [ Mon 29 Jul, 2019, 17:21 ]
Post subject:  Re: chart error on strategy start

There is important thing to understand : After platform restart you didn't have last active chart entity, because you didn't have any active chart until moment when you will do any action with this tab.
        Set<IChart> charts = context.getCharts();
        List<IChart> usdjpyCharts = charts.stream()
                .filter(chart -> chart.getInstrument().equals(Instrument.USDJPY))
                .collect(Collectors.toList());

You can get a list of all your charts and filter them by some parameters.

  Page 1 of 1