After we create a strategy we need to compile and test it and if everything goes well, use it on "production" environment. Maybe all of us know how to do that, but probabily there are the ones who don't know how to achieve this. In this article i talk about how to compile, test and do historical tests with a strategy (if applicable) or indicators as well. For that we can use directly the sources provided with JForex API (testeMain and testerMainGUIMode), but this is somewhat more complex than using JForex client itself.  By this reason i only talk about using JForex client to do this work (if you have some doubts about using the API sources directly just ask and i will see if i can help if i know how to answer). In past articles i provided some basic strategies to understand the basic functionality and in last one i provided two strategies that do something usable. In other article i have presented other strategy where we extend JForex functionality with one different approach for market hours. You can use them to go over the steps on this article. Probably i will talk about indicators details (programming details) and how to use them on our strategy in next article.

Compiling a strategy

To compile a strategy, the first step is open it on JForex client. We can do this in several ways showed in next image.

Image 1: How to open a strategy in JForex Client. Explained steps below.

First way:
  • 1 - Right click on "Strategies" in the tree on "Workspace" panel;
  • 2 - Click on "Open Strategy" menu item.
Second way:
  • A - Select "Tools" menu;
  • B - Select "Strategies" menu;
  • C - After this, we have a new tab separator at the bottom named "Strategies";
  • D - Click on "Folder" icon.
  • As result of our actions we get a window pointing to our file system (red rectangle). We need to find the directory where our strategy is, select it and click open;
  • Note - the source file of our strategy have the file extension ".java". The compiled strategies have the file extension ".jfx" and can't be open unless we have the corresponding source file in same directory (in this case the JForex client open the source file). 
Suposing we have our strategy ready to compile - if not, on the resulting window we can use the editor window to edit/change our strategy. We have three choices to compile our strategy as we can see on next image:

Image 2: We can compile a strategy in several ways. Also, we can see the compiling results. Details explained below.

In this image we have slices of diferent ways to compile a strategy (green numbers at right):
  • 1 - We can compile  a strategy clicking on the upper center "compile" icon inside red rectangle;
  • 2 - Here we cab see two ways to compile - first way is right click on our strategy at left and select "Compile" - the other way is selecting the strategy we want to compile on the "Strategies" tab and click on "compile" icon.
  • 3 - If everything goes well, we are presented with "Compilation sucessful." message on "Messages" tab and we are ready to run this strategy;
  • 4 - If our code have some problem, we get the errors on the "Messages" tab. There we can find the line where the error resides and some description of the erros that helps us to resolve it or them editing the code on the editor or on external editor if we use it.

Running a compiled strategy

Running a compiled strategy is simple. you have two choices as stated on next image.

Image 3: How to run a strategy, a running strategy and the output of strategy at bottom tab.

You can run a strategy by right click on it on "Strategies" tree and select on menu "Local Run" or "Remote Run" if you have access to run strategies on Dukascopy servers (i think this is the objective, but not 100% sure). Other way is selecting the strategy on "Strategies" bottom tab, select the environment on red rectangle and run it clicking on "Run" icon on green rectangle ("Run" selected, "Stop" selected and "Stop All" strategies icons respectively). All of this on identified area "1" in green at the right.
On area "2" you can see the running strategy icon status, starting time, stop time (if applicable) and again the status of the strategy (on blue rectangles).
Area "3" shows one example of one running strategy where the output is directed  for a new tab at the bottom area. The strategy can also create a new tab with his name where we get some log output .

Backtesting a strategy (if applicable)

To see if our strategy (if a automated trading strategy) match our expectations we have a fast way to test it before trying it on DEMO accounts and after on LIVE accounts. For that we can use "Historical Tester" and test our strategy on large periods of time in a fraction of time if we use DEMO or LIVE accounts. For example we can test a strategy over a period of several months or years of feed data (feed data identical to the market evolution along this time) in minutes or hours depending on our system, internet connection (to get the feed data) and the processing overload of our strategy.

WARNING: Consider the results obtained on "Historical Tester" test as just a indication as we can get different results when our strategy runs on DEMO. Also consider the results on DEMO as indication because you can get different results on LIVE. Use it only to take a general ideia if the strategy has the potential to be profitable or not. The results can differ because we have to take on consideration other factors not present on tester environment or DEMO environment.

To test a strategy we must access "Historical Tester", a tab present at the bottom of our JForex client. On next image i explain how to open and explain the options present on it.

Image 4: Historical Tester and the options on it. Explanation below.

  • Pink rectangles: To open the "Historical Tester" tab, we click on tools menu and "Historical Tester" menu item.
  • Red 1: In this dropdown box we can select a open strategy - we need to have it or them open and compiled (or only compiled if we only have the ".jfx" file). We can use the open button or if we have it on "Strategies" tab list it/them is/are available on the dropdown list.
  • Red 2: Account settings - In this window we can define the initial value present at our test account, the base currency, the max leverage we can use, margin call over account value and over equitity. Also we can define the commission rates and overnight rates, but the default ones, are the ones in use by Dukascopy at the moment.
  • Red 3: Instruments - In this window we can select one or several instruments (currency pairs) to use on our strategy. If our strategy use one or more we must have it/them selected. Take in consideration the more you have selected greater the volume data the platform have to download from Dukascopy servers. If you don't need a pair, don't select it.
  • Red 4: Interval time: Here we can select a predefined interval present on the dropdown box or use a "Custom interval" to define the desired time interval between where our strategy runs on historical data.
  • Red 5: Period filtering -  In this dropdown box we select the period filtering. "Ticks" is the most precise data processing but the slowest one, as we receive and process all ticks generated on market over the interval time considered. If we select larger periods, the data is based on OHLC (open, high, low, close) using 4 ticks with this data. Also we must define if we want to use "Bid" or "Ask" prices on the dropdown box at right wich is available if we select this options.
  • Red 6: Tick or OHLC filtering  - In this dropdown box we can select the tick filtering over several options (tick differences, tick direction, tick direction, tick time interval) if we have selected "Ticks" in last dropdown box. The most precise processing is "All ticks". If we have select before other period filtering, the filters on this box are "4 ticks at OHLC", "Cubic spline", "Tick on open" and "Tick on close". The most precise processing in the period filtering is the first selection.
Final words

I don't have more space in this article, i will continue this theme on the next one.
Trade well and prospers in your way!