Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

chart error on strategy start
 Post subject: chart error on strategy start Post rating: 0   New post Posted: Sat 27 Jul, 2019, 14:36 

User rating: 0
Joined: Sun 14 Apr, 2019, 13:15
Posts: 3
Location: Poland,
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?


 
The Best Answer  Post subject: Re: chart error on strategy start Post rating: 0   New post Posted: Mon 29 Jul, 2019, 17:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
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.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com