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.

Execute a strategy at the end of another
 Post subject: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 10:12 

User rating: 0
Joined: Thu 17 Oct, 2013, 09:50
Posts: 5
Hi,
having a simple strategy that works in historical tester, I would need to perform, automatically, the same strategy several times with different parameters.
In substance, at the end of a strategy, it must initiate another, in automatic.
So the idea is that, on OnStop event, there must be something that performs the same strategy or another instance of the same strategy.
ITesterClient and startStrategy can help me in this?
I would like to have a basic code that does what I said. I've tried it alone, but the code in circulation did not help me.
Thank you.


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 10:27 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Starlink wrote:
So the idea is that, on OnStop event, there must be something that performs the same strategy or another instance of the same strategy.
ITesterClient and startStrategy can help me in this?
ITesterClient executes the strategies sequentially (not in parallel as the IClient does), thus if you will call ITesterClient.startStrategy on the same strategy twice, the second instance will start right after the first one will have finished executing. To achieve the same effect with IClient (i.e., strategy run with in-progress data) you will need to process the SystemListener.onStop event in such a way that it triggers the next strategy instance start, see:
https://www.dukascopy.com/wiki/#JForex_SDK/System_listener


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 11:00 

User rating: 0
Joined: Thu 17 Oct, 2013, 09:50
Posts: 5
It's fine that a strategy starts only when the previous one ends, but I would like to have a "skeleton" of the whole class (including package and import), which launches a series of strategies in sequence. Can you give this? The clips of strategy does not help me ....


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 11:33 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Simply modify the TesterMain example of the JForex-SDK project to call the MA_Play two times, i.e.:
client.startStrategy(new MA_Play());
client.startStrategy(new MA_Play());


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 11:39 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

This topic might be useful for you.


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 12:06 

User rating: 0
Joined: Thu 17 Oct, 2013, 09:50
Posts: 5
Thank you very much!
I get various errors on LOGGER because I do not have the library org.slf4j.
I think it is only for viewing info: can I use the JForex console (console.getOut().println) without utilize that external library?


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 12:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Starlink wrote:
Thank you very much!
I get various errors on LOGGER because I do not have the library org.slf4j.
Consider importing a "fresh" version of the JForex-SDK project and there should not be any such logging library problems, see:
https://www.dukascopy.com/wiki/#Use_in_Eclipse
https://www.dukascopy.com/wiki/#Use_in_NetBeans
Starlink wrote:
I think it is only for viewing info: can I use the JForex console (console.getOut().println) without utilize that external library?
Simply fetch an IConsole object from a started strategy.


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 15:22 

User rating: 0
Joined: Thu 17 Oct, 2013, 09:50
Posts: 5
Well! And how can I do? ;-)


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 16:06 

User rating: 0
Joined: Thu 17 Oct, 2013, 09:50
Posts: 5
In addition, in TesterMain, I replaced MA_Play with the name of the strategy that I want to run (already compiled), but the editor displayed error "(filename) can not be resolved to a type". So something must be done, in principle, to declare the strategy to be implemented? So TesterMain does not work as it is !


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Thu 17 Oct, 2013, 17:58 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Just a wild guess: Is the strategy is in the same package?
The first valid (non-comment) line in the strategy declares the package.
It is singlejartest, or simplejartest for the SDK...

If this is not the case, and your own strategy has the same package declaration, then I suggest to provide (attach) your source tree (include TesterMain.java, and your own strategy), so we can check what is going on.


 
 Post subject: Re: Execute a strategy at the end of another Post rating: 0   New post Posted: Fri 18 Oct, 2013, 09:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Did you follow the offered fix options of your IDE?


 

Jump to:  

  © 1998-2026 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