As traders we need all tools we can get the hands on to obtain a “edge” over the market. If we are a Dukascopy Bank trader we have severall ways to implement our trading activity. We can access our accounts and do our trading activity in different ways: by web interface, by smart phones (iphone phones and now android phones too), by JForex Client, some other platforms builded using JForex API. Also we can do our activity with Metatrader bridge but don’t is our objective to talk about it. With this article we are trying to introduce the JForex API to you, the reader, as we use JForex Client ou other any JForex API based platform. With it we can implement tools, change the aspect, build indicators or, what you are probabily more interessed, strategies (for automated trading or to help us on manual trading). For that we need to learn Java.
JForex Client and JForex API is developed using Java programming language and it's VM. To do anything useful with them, we need to know this programming language. Great number of us maybe don’t know about this programming language, but want to know about it. Maybe we don’t have the time to seach information or to find the useful information about it. I will provide some references i think useful to learn about Java programming language:
Programming methodology and Java video course: one of the best free courses i found in internet and available to anyone is presented by Stanford University in their YouTube channel. It’s a great course and worth the time spended to see it (28 class lessons with more than 40 minutes each one). If all teachers are as the one who gives this course certainly we have better schools and students. You can access this course here.
Free book about Java: Thinking in Java by Bruce Eckel 3ª edition is a good learning book and you can get it here (4ª edition don’t is available for free).
Other great free book about Java and if you are a totally newcomer to computers in general this is book is for you: Java Notes 6ª edition by David J. Eck.
- Java resources and examples: This site is well organized by category and with good examples to achieve what we need. You can access it here.
- At last but not least the Oracle (the actual owner and developer of Java ) reference itself can be accessed here.
Of course this are only suggestions and you can find other sources of information by yourself, but they are a good start. To work with Java usually we need the Java Development Kit (JDK for simplicity - you can get it here) and use one Java editor. There are the “purists” who say you to use notepad on your learning path, but if we can have tools to make our life easiest why not to use them? The best tools to work with Java are Java IDE (Integrated Development Environment) software. JForex client have a good editor and is very usable, but for me, as i’m habituated to it, i prefer Netbeans or Eclipse and they are available to all operating systems where Java works. If you search Google you find them easilly.
With some of the needed knowledge and tools available we need to know where to find the information about JForex API. This information is only available officially at Dukascopy Site (and maybe on other sites where JForex is the theme):
Dukascopy wiki: great source of information about JForex API parts with good examples and use cases (examples of utilization). You can access it here.
JForex javadoc: Documentation generated by information provided on original code of the api with the information how to use specific API items. In Dukascopy site this information is always on date with javadoc for last version available. Also you get it in zip format inside the JForex API download file and you can read it directly or associate it with your project on the IDE editor you use. You can access it online here.
- Dukascopy forum: Here you can get answers to problems encontered, doubts about the API or how to achieve something. Also you can ask the Support Team to build a strategy that match your specification but i think if you have the oportunity to build it yourself you will do it. The community and the Support Team are very responsive. You can access this forum here.
- onStart(...) : Every time we run our strategy this is the first method executed. Is used to initialize objects and variables needed on our strategy based on received Icontext (the interface that allows interaction with the platform itself) and other variables or use other methods.
- onTick(..) : This method is executed every time a tick is received from data stream from Dukascopy. In this case the parameters are the instrument in use (for each one subscribed) and the Tick information itself. Usually we use this method to calculations on every tick received and do whatever we want with it.
- onBar(...) : This method is executed every time a bar is finished for each subscribed instrument. Also this method acts the last one but on bar completion. To work correctly it needs the instrument in use, the period of the bar, and the values for ask and bid bar objects where is filled with values of open, high, low and close price, the timestamp of the start of the bar and the volume value that occurred on this bar.
- onMessage(...) : This method is executed on every message sent by the platform itself (the parameter). Most of the time is used to control the orders status and receive informations about when something occurs with and manage them. Also we can use it to get market news for example. See javadoc for more information.
- onAccount(...) : Is executed when something changes our account, change on equitity for example, get profit or loss of orders etc (javadoc and wiki are your friends).
- and finally onStop() : is executed when we stop our strategy. Can be used to do something we need at the end of the strategy: save configurations, print logs, close windows or objects etc.