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.

multiple files and OO programming
 Post subject: multiple files and OO programming Post rating: 0   New post Posted: Sat 10 Apr, 2010, 17:20 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
How do I split my strategy into multiple java files so that I can share methods between strategies? I'd like to take an object oriented approach to my design structure rather than a procedural process as seen from various examples so far.

The problem arise when I try to compile a file. The compiler forces the java class to implement IStrategy or IIndicator. Whereas I just want the class to act as an OO object.


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Mon 12 Apr, 2010, 10:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
at the moment, it is possible to import external library's. Here is sample https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=7&t=225&p=3666&hilit=send+mail#p3666


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Mon 12 Apr, 2010, 17:03 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
Perhaps I was unclear. Here's an example.

Say
class Strategy1 implements IStrategy
. In Strategy1.java, I want to call method ManageRisk(IAccount, IOrder, IInstrument). It works fine if and only if ManageRisk() is in same .java file as Strategy1.

But if I create an external class file, Risk.java, to hold ManageRisk(), I would need to import com.dukascopy.api.* in Risk.java for using IAccount, IOrder, and IInstrument, etc. This is where the problem arise.

I tried to compile Risk.java in JForex and the compiler says that Risk.java needs to implement IStrategy or IIndicator.


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Tue 13 Apr, 2010, 08:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please, use an IDE (for example Eclipse) for development and creation your library.
Here is tutorial https://www.dukascopy.com/swiss/english/forex/jforex/library/
If you still have questions, please don't hesitate to ask.


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Mon 19 Apr, 2010, 23:49 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
If I use an IDE, can I load the developed strategy (in multiple files) into Historical Testing or Run it in the platform?


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Tue 20 Apr, 2010, 01:18 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
Hi Quantisan,

yes you can, we have been using netbeans of late and it has been working out well for use in the backtester, etc.. The IDE is very light compared to eclipse, but there are somethings to get used to when you have project dependencies and when those dependencies have dependencies. For now with a normal library project, I have created this library which I built to take care of trade information, etc. I use this library by putting it in my "files" folder (found within the Dukascopy defined strategies path).
Then within your Strategy class that implements IStrategy...put @Library("name_of_lib_in_files.jar") along with your import statements.

Hope this helps and if you end up going along with netbeans, feel free to pm me for some extra advice :)

all the best,
jUser


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Tue 20 Apr, 2010, 03:06 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
Thanks JUser. I will try Netbeans soon. is there any sample source code available in this forum relating to this question? Like how to use @Library etc.?


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Tue 20 Apr, 2010, 08:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes,
here you will find samples:
Here sample with @Library https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=7&t=225&p=3666&hilit=send+mail#p3666


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Tue 20 Apr, 2010, 21:10 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
Thank you for the link. But the URL to forum posts only lead to the index. Were they intended for individual post? If so, could you please repost the link?


 
 Post subject: Re: multiple files and OO programming Post rating: 0   New post Posted: Wed 21 Apr, 2010, 07:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Look at the last one https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=7&t=225&p=3666&hilit=send+mail#p3666 ;)
Other posts lead to forum topics where you can find lot of different samples.


 

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