|
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 |
[quantisan]
|
Post subject: multiple files and OO programming |
Post rating: 0
|
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.
|
|
|
|
 |
API Support
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
Posted: Mon 12 Apr, 2010, 10:44
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[quantisan]
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
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.
|
|
|
|
 |
API Support
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
Posted: Tue 13 Apr, 2010, 08:31
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[quantisan]
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
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?
|
|
|
|
 |
MoneyMechanics
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
Posted: Tue 20 Apr, 2010, 01:18
|
|
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
|
|
|
|
 |
[quantisan]
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
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.?
|
|
|
|
 |
API Support
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
Posted: Tue 20 Apr, 2010, 08:04
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
[quantisan]
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
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?
|
|
|
|
 |
API Support
|
Post subject: Re: multiple files and OO programming |
Post rating: 0
|
Posted: Wed 21 Apr, 2010, 07:35
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|