Forewords

This article is a first part of 3 part series of articles about strategy testing in customized JForex. I’d like to show to readers how JForex libraries can be easily used in building custom strategy trader/back tester. The idea behind my articles is, that when one needs to implement some more complex trading algorithm containing tenth or even hundreds of Java classes, requires some custom UI, needs opportunity to debug it would be beneficial to break free from JForex back tester and develop custom program using JForex libraries.

The article series presumes reader has got at least beginner knowledge level of Java programming language, basic familiarity of Java Development Kit, and ideally PowerShell scripting overview or at least working Windows knowledge.

Personally I’m very interested in area of automated / algorithmic trading and as a professional software developer having good command of several languages I’ve found JForex platform like the best option to develop automated strategies on. In this first article of the series I’d like to show you how to download all necessary libraries of JForex and use them in simple Strategy implementation.

II. Get JForex libraries

The very first thing we need is to have all required libraries downloaded onto out hard drive. To do this we need first to analyze JNLP file. JNLP file is that file we are using to start standard JForex platform. Let’s see how it looks like:


We need to focuse on line number 39 having following content:

This line tells us URL address were we will find another JNLP file containing list of libraries we need to download for referencing purposes later . Let see how the libs_3.jnlp looks like:



Here we need to get url were we can download libraries from specifically http://platform.dukascopy.com/demo_3/ (this URL does not work alone) and list of jar files we will download. For download each jar we need to build up URL which is simply combination of URL and content of href attribute of each particular jar file.
So e.g. URL for downloading lucene-highlighter-3.4.0.jar file:

http://platform.dukascopy.com/demo_3/lib/lucene-highlighter-3.4.0.jar


Now we have two possibilities how to download jar files.

II. I. Manual Download

We can manually create list of URLs as I showed above i.e. constructing each single URL by combining code base and jar’s href. We can use those url directly in any browser. When we put URL in the browser's address bar we are asked to save the file, so we can do it by selecting are target folder and click on ok. This required us to do it for all jars one by one.

II. II. Download by PowerShell script

Since we live in 21st century we can use some more sophisticated method how to download jar files. I’ve prepared PowerShell script for you which download all files to the folder were the PowerShell script file resides in. You can find the script as public Gist on GitHub available on link bellow

https://goo.gl/0KPrKe



Steps to run the scripts:
  1. Create empty directory on your hard drive, were the script and library files will be downloaded.
  2. Go to url for RAW Gist https://goo.gl/lu1mrG and save the page as JForexLibrariesDownloader.ps1 into the directory you created in step 1.
  3. Go to the folder and right click on JForexLibrariesDownloader.ps1, select Properties of file and grant running permissions by Unblocking the file.




  4. Run the script by righ click on the ps1 file and select “Run with PowerShell”




The script should download 2 jnlp files (jforex_3.jnlp and libs_3.jnlp) in the same folder as ps1 script, and should create jforex3libs folder with all jars we need for creation our custom strategy trader.

III. Quick console test

So now when we have all required libraries we can make some test.

  1. Download JForex SDK
  2. Place Main.java and MA_Play.java into the directory with ps1 script



  3. Modify Main.java, find user name and password and replace them with your DEMO account credentials



  4. Create bin subfolder where class files generated by compile will be placed
  5. Compile the java files with following command (assume your local JDK is on system PATH)

    javac -cp ./jforex3libs/* *.java -d bin

  6. Run the strategy by following command

    java -classpath ./bin;./jforex3libs/* singlejartest.Main

  7. When you start the strategy you should see how the strategy is connecting to Dukascopy servers, subscribing currency pair and see Started


IV. Summary

This article had intention to user be able to download all necessary JForex libraries (jar files) to build up custom trader and back tester. In next part I'll focus on creating some JavaFX GUI connected to Dukascopy server.
Translate to English Show original