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.

onStop() "slaughter"
 Post subject: onStop() "slaughter" Post rating: 0   New post Posted: Wed 20 Jan, 2016, 13:52 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 39
Hi,

I have strategy that onStart() creates a lot of chart objects and onStop() destroys those objects. Unfortunately recently it takes much longer to start and stop the strategy. JForex kills strategy 20 seconds after I requested stop, before onStop() is finished, with following message:
Quote:
09:20:25 Strategy "SChartDashboard" is stopped at 2016-01-20 09:20:25.163 GMT on the local computer with parameters [...cut...]. Reason: Stopped by Engine
09:20:25 java.lang.ThreadDeath @ java.lang.Thread.stop(Unknown Source)
09:20:25 Killing strategy thread [cy]

09:20:05 Stopping "SChartDashboard" strategy at 2016-01-20 09:20:05.159 GMT on the local computer
09:17:16 Strategy "SChartDashboard" Strategy ID: 9352A93E5A4F0A4983DC44218BE13F63 is started at 2016-01-20 09:17:16.420 GMT on the local computer with parameters [...cut...]
09:17:16 Starting "SChartDashboard" strategy at 2016-01-20 09:17:16.389 GMT on the local computer
09:17:14 Compilation successful. Strategy ID: 9352A93E5A4F0A4983DC44218BE13F63
09:17:13 Compiling SChartDashboard.java


  • What can I do to prevent this? Can I extend this 20 seconds time?
  • Is there any special way to use indicators and chart APIs to speed up the process? My perception is that recently indicators API and charts API work slower. Is it true? Should I use API in other way than before?
  • Why chart.remove( objectKeyString ) takes so long? Should I use pointers instead of string keys?

Regards,
FXer

Windows 7 Professional
JRE version 1.8.0_72-b15 Java HotSpot(TM) 64-Bit Server VM


 
 Post subject: Re: onStop() "slaughter" Post rating: 0   New post Posted: Wed 20 Jan, 2016, 15:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
A simple solution could be to have secondary strategy that removes all of the charts objects.
When the main strategy is stopped it could send engine.broadcast("title", "message"); message to the secondary strategy to remove the objects.


 
 Post subject: Re: onStop() "slaughter" Post rating: 0   New post Posted: Wed 20 Jan, 2016, 23:32 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 39
Thank you for the hint - it is very useful and I am sure I will use it soon :-)

Finally I've decided to move from code similar to this:
for( IChart chart: charts )
    for( IChartObject o: chart.getAll() )
        if ( o.getType() == IChart.Type.SHORT_LINE )
            chart.remove( o );

to code like that:
List<IChartObject> l = new ArrayList<IChartObject>();

for( IChart chart: charts ) {
    for( IChartObject o: chart.getAll() )
        if ( o.getType() == IChart.Type.SHORT_LINE )
            l.add( o );
    chart.remove( l );
}


The latter example is several times faster (maybe as much as 50-100) :o than first one (more than 30 seconds vs. fraction of second). I am really surprised, because I was not expecting such tremendous performance difference...

BTW, are there any methods for bulk chart objects creation?

Regards,
FXer


 
 Post subject: Re: onStop() "slaughter" Post rating: 0   New post Posted: Thu 21 Jan, 2016, 07:40 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Quote:
BTW, are there any methods for bulk chart objects creation?

No


 

Jump to:  

cron
  © 1998-2025 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