This article will help people who are new to Visual Jforex when testing/developing a strategy. It explains the following:
  • How to set up variables that can be easily changed after the strategy has been built.
  • How to view Vjfx strategy source code & test a Vjfx strategy in Jforex.*
*In my experience, Jforex backtesting is faster. It also allows for multiple charts and provides a trade report (showing individual trades) at the end of a backtest.

How to set up variables that can be changed after the strategy has been built.

(All images can be enlarged by clicking on them.)

Global variables are variables that can be changed after the strategy has been built, without the need to go back and edit the strategy. They are very useful during testing or if you need to make regular adjustments to the strategy.

When a strategy is executed a window will appear. Every strategy starts with 6 default global variables. If it is run in Visual Jforex it will show a "Global Variables" window. If the strategy is run in Jforex it will show the "Define Parameters" window:

The “defaultPeriod” variable indicates the timeframe on which an indicator runs, i.e. Simple Moving Average on Hourly timeframe.

As you can see there is only one default period for the timeframe but no default period (how many bars to process) for the indicator, i.e. 30 period Simple Moving Average.

Setting a variable to global makes it appear in the start window:

To set a variable to global, go to the block which contains it and move the mouse to the area shown (red circle) in the screenshot and click on the edit button (red circle) that appears:

A menu will pop up (see image below):
  • Start by entering a name for the variable (1).
  • Then click on the “Global" field (2).
  • Select “true” (3).

After this is done the variable will appear in the “Global Variables” or “Define Parameters” window next time the strategy is executed. You can set all the important variables to global.

How to view the Vjfx strategy source code & backtest a Vjfx strategy in Jforex:

If you have not already built the strategy, you need to click on "Compiler" (top left corner) and then click "Build". Then proceed with the following steps:
  1. Select “My strategies”.
  2. Find the open strategy from the list (see example).
  3. Right click on the strategy and select “View Source”.
  4. The strategy source code will appear in a new window.

To backtest a strategy in JForex you need to copy the code and compile it in Jforex. Click in the window and press CTRL + A (or use the mouse) to select all the text, then CTRL + C to copy it.

Open Jforex, then right click on “Strategies” (1) in the “Workspace” area and click on “New Strategy” (2). Once you do this a new window will open (red arrow).

Select all the code in this window, delete it and then paste the copied code from Visual Jforex into this window (3). Click on the
“Save As” (4) and click on the "Compile” button (5) after you have saved the file.Now you can backtest your strategy in Jforex using the historical tester which can be found under the “Tools” menu.

You can select “Visual Mode” to display a price chart while testing the strategy. If you right click on the chart's tab you can
select “Clone Chart” and then change the timeframe or chart type to see exactly where trades are opened on different charts. You can use the "Arrange" sub menu to change the window layout similar to the image shown below:

Jforex provides you with a trade statement at the end of a test and allows you to use multiple charts, while Visual Jforex provides a more statistical report at the end. I usually test a strategy in both.

  • Please let me know if you found this article useful by clicking "Like" and leaving a comment. Any feedback is appreciated. If you have any questions, please leave them in the comments section and I will answer them asap.
Translate to English Show original