Article Library

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
Read article
Translate to English Show original
CharmingRimma avatar

nice explanation

ak10 avatar
ak10 15 June

I have started developing strategy in Java. I will request you to post one blog or article for middle level strategy developers like me. Your article is new concept. Hope you win.

mcquak avatar
mcquak 15 June

@ak10 thanks. The 2nd part I'm working on now will be about using these jars we downloded in thi article in project in IntelliJ Idea hence having debugging features available, having JavaFX ui with simple observable currency pairs dashboard etc. Will host source code on github.

salamandra avatar
salamandra 17 June

very good

foreignexchange avatar

mcquak  Thx : )

orto leave comments
In my recent articles I was focusing on strategy hypotheses checking and strategies paper-trading in R. So all of these activities with so much of development effort in it bring a valid question. Is there any value in such backtesting and hypothesis checking? My answer is definitely yes, and I'm going try to persuade you about it.
Why doing back test in R when my strategy runs in Java/JForex?
This is valid question. Why anyone would be bothering writing thousand lines of code without any possible reuse?
First of all R is good for quick strategy prototyping. Before we would be bothering to write single line of code in Java, it's better to assure that our strategy is profitable. And R is very good tool for it. Ok, fair enough so far. However this would lead us to justified worries about rewriting whole strategy that we potentially have in R to Java. This could be potentially quite big issue since libraries we are used to use in R usually do not have their opposite siblings in Java world. So my personal intention about strategies being written in R is to be able to reuse as much from the code base in R as possible. How?
Reuse R code in Java/JForex? Use Renjin!

When I was starting inv…
Read article
Translate to English Show original
mg64ve avatar
mg64ve 26 Dec.

Dear mcquack, I have tried to implement the R-Java integration as per your article.
I am not using IntelliJ, I am using JForex.
I successfully installed rJava in R and modified the path in Linux.
Unfortunately, if I try to compile your strategy I get:

14:17:32 The import org.rosuda cannot be resolved

Do you have an idea where JRI.jar has to be copied?

cbennici avatar
cbennici 7 Jan.

hi mcquak.

I've  installed properly Rjava and  load the library: '@Library ("C: /Users/calog/JForex/libs/demo_3/3.0.15/JRI.jar")'. The strategy compiles regularly.
At a time when initializing the Rengine "Rengine re = new Rengine (new String []  {" - no - save "}, false, null);" is executed  the platform closes unexpectedly without saving anything.

Rjava under JForex have been tested under Windows 10?

mcquak avatar
mcquak 7 Jan.

cbennici, I've made tests under Windows 7, but it's definitely not a problem.
I did not use standard JForex platform for testing but I used my own local tester built up from JForex .jars so I could  run and debug whole platform from within IntelliJ Idea (which is great for debugging purposes).
I guess for R to be callable from standard JForex platform, you'd need to made some changes in the strategy. If I'm not mistaken there is some metadata attribute that allows to import/reference jars in the platform (see screenshot).

mcquak avatar
mcquak 7 Jan.

mcquak avatar
mcquak 7 Jan.

mg64ve Hi, pls see my 2nd post above, it's perhpas tha same problem. For using/referencing external jars in JForex you'll need to reference them via metadata attributes. @RequiresFullAccess and @Library("PATH_TO_JAR").

orto leave comments
I’ve been investigating volume profile and market profile strategies for some time now. Personally I’m convinced that even though spot currency market is decentralized without any authority like regular exchanges does have, volume still matters. Hence I’ve been flirting for a while with an idea writing custom tick volume profile indicator myself. With this article I’d like to share my code with you. And because this is my first attempt of graphical indicator I’d be very grateful for any constructive criticism especially from performance point of view
Let me sketch my basic idea I was thinking of before I’ve started writing the code. I wanted to create vertical histogram showing collective tick volume per each price level reached during some period of time. As a simple start I’ve took 24 hours range counted from midnight. The result looks like on following screenshot
Full source code is available on github [1]. I'd be really grateful for any constructive technical discussion under the article, so please feel free to leave your opinions.
My further intention with this indicator is to improve it specifically in following areas:
1. Drawing performance
2. Add Point of Control (POC) and[/1]…
Read article
Translate to English Show original
Sennna88 avatar
Sennna88 14 Apr.

very good article, keep up the good work

semperaugustus avatar

VolumeProfile gives outofbound exceptions.

CrossD avatar
CrossD 4 Feb.

Hi Tomas! Can I contact to you to get info about the indicator?

thinhpv avatar
thinhpv 20 May

How can I install it in jforex :(

fso56 avatar
fso56 4 Sep.

Hello. I can't add indicator on Jforex 3. You can fix it. Thank You

orto leave comments
Hello everyone!
In my past I spent 3 years for manual trading, before I commenced to feel myself tired of constant repeat of the same actions.
Also I realized that I can't create my new trading system without making of custom indicator. This forced me to study programming.
Now I want to share with you my experience. I'll show you how it's possible to learn JAVA at home.
Who is this article for?
  • If you wish to program your own indicator or strategy, to automate your trading - this article is for you!
  • If you're new to FOREX, you're in search of your own trading system and don't know where to begin - this article is also can be useful for you!
  • If you don't want to spend years trying to become a professional programmer and wish to limit your knowledge, by learning only restricted variety of tasks - this article is for you!
Read article
Translate to English Show original
ivan_taranov avatar

Peggy37 I saw a version for Linux, but didn't use it

Peggy37 avatar
Peggy37 1 Apr.

I found, thanks, hope it will be working.

ivan_taranov avatar

Peggy37 You're welcome!

ikszy avatar
ikszy 8 Apr.

You succeeded to be short and simple. Though I am just the 2nd category (beginner), it gave me a push what to do after the necessary manual trading, thanks.

ivan_taranov avatar

ikszy Glad to be useful!)

orto leave comments
JForexUtils - A collection of useful java classes for JForex - Part3
Welcome to the third part of the JForexUtils documentation.
In case you missed previous parts:
Part 1
Part 2
All project links are listed at the end of this article.
In this part we will cover the very central context of order submission and change.
The tools for these tasks are easy to use and can be configured for complex scenarios.
All examples can be downloaded as a java file in the ExamplePart3.
Class OrderUtil
This important class handles all order creations and changes.
In Part 2 we've seen how to create an OrderParams object which holds all parameters for an order.
Let's start to use this orderParams object to open a new order:
1)Submit new order to server
This was fairly easy with the help of the orderParams object!
In the first line we create the orderUtil instance and in the second line we pass our previously created orderParams object to the submit method.
This is the minimal use case for opening a new order.
You may have a few questions though:
Q1 Where is the created order?
Q2 What if an exception was thrown; where is it and aren't we supposed to catch it?
Q3 What if the submission was rejected by th…
Read article
Translate to English Show original
orto leave comments
JForexUtils - A collection of useful java classes for JForex - Part2
Welcome to the second part of the JForexUtils documentation.
In case you missed part 1 and want to start from the beginning -> Part 1
In this part we will see how to do pip and amount conversion calculations as well as fetching quotes for an instrument. Finally, we see how to easliy create order parameter instances which are later used for submitting orders to Dukascopy servers.
All following code snippets/pictures can be found as a Java file in ExamplePart2.
All links are listed at the end of this article.
Class CalculationUtil
This class has two aspects: the first are static methods for which you don't need an instance. The second covers calculations for amount conversions between currencies and instruments. These require an instance of CalculationUtil since it relies on live market data.
1)Static pip and amount calculations
Line 1: This method scales an amount to lots; one lot of the JForex platform is represented as 0.1. So the result in the example is 0.12345678.
Line 2: Here the signed pip difference of two prices of an instrument is calculated. The result of 1.12887-1.12743 is 14.4 pips. If you swap the pri…
Read article
Translate to English Show original
Kbelestro avatar
Kbelestro 16 Feb.


Olkiss70 avatar
Olkiss70 21 Feb.

very important work!

zarina avatar
zarina 27 Feb.

it's about programming ?

Nihad avatar
Nihad 27 Feb.

Brilliant, working on a similar project for statistical functions.

FXjuxe avatar
FXjuxe 28 Feb.

@Nihad: Thank you. I also implemented a bridge between JForex and "R". When I have time I will present it here.

orto leave comments
JForexUtils - A collection of useful java classes for JForex - Part1
Dear JForex programmers,
if you have ever felt that strategy programming in JForex is sometimes a cumbersome task, then you will find some help in this and upcoming articles.
I've developed a Java library with lots of tools which greatly simplifies strategy development.
I share this library with you and will describe its features and use cases.
As a preview here are some of the major features you will be able to use:
* Useful tools for creating currencies and instruments
* A very easy to use builder for order parameters
* A powerful class for all order submission or changes. It is thread safe and you can send order commands directly from all threads with one consistent API
* With the help of a calculation tool you can do pip math tasks, convert order amounts etc.
* Quote classes provide an easy way to get the latest ticks/bars. They are also very fast which pays off when doing long backtests
* The most complex class is able to do a merge operation in one go!

Hopefully this preview has quicken your appetite
Please obey these prerequisites:
[list]This article series is for experienced(!!)
Read article
Translate to English Show original
Natalia_Kisenko avatar

excellent work!  are you a programmer?

FXjuxe avatar
FXjuxe 12 Feb.

Thx, I work as software engineer for a big telecommunication company.
I developed this library in my spare time.
The real cool stuff is still to come in the follow up articles.

sonjatrader avatar

good article

CriticalSection avatar

well done FXjuxe - keep up the good work!

Olkiss70 avatar
Olkiss70 21 Feb.

very useful!

orto leave comments
Каждая проблема имеет решение. Единственная трудность заключается в том, чтобы его найти.
Эвви Неф

В этой статье расскажу о проблеме, с которой столкнулся в Июне 2015 . Проблема состояла в том, что в одно и тоже время, стали происходить пропажи соединения с терминалом Jforex . На решение этой проблемы было потрачено 2,5 месяца .
Каким образом происходило решение этой проблемы и как были выявлены причины . Будут подробно описаны мной сегодня . По крайней мере, кто-то сохранит кучу времени при наличии подобной проблемы .
Поиск решения проблемы напоминал мне блуждание по лабиринту . Но, до того момента пока не было найдено решение.. Как , оказалось была основная причина и несколько второстепенных на качество соединения и загрузку канала связи . Итак, обо всем по порядку .
Пропажа коннекта
В начале Мая 2015 года был сменен интернет провайдер . Стал использоваться интернет провайдер предоставляющий спутниковый интернет . Главной особенностью данного провайдера пинг от 700 до 820 мл секунд.
Пропажа соединения наблюдалась в основном во временном отрезке с 10-25 и 10-40 . Интересным моментом ,оказалось после данного ценового отрезка в основном свзяь не пропадала .
Read article
Translate to English Show original
Skif avatar
Skif 29 Jan.

Thanks for the support guys !!!

alias1980 avatar
alias1980 30 Jan.

молодец... полезная статья!

alias1980 avatar
alias1980 30 Jan.

нагрев проца выше 75С - это вообще фигово особенно для AMD. При нагрузке на проц будет за 90С что уже критично....

TaniaS avatar
TaniaS 31 Jan.

Очень интересная и полезная статья)

AnastasiyaBauer avatar

отличная работа

orto leave comments
Before continuing I would reccomend to read the previous steps where I explained the bases and some core concepts. You can find them following these links: part 1 here and part 2 here.
The fourth element

The concept is always the same: everything has a clear (eventually complex) function but has to be as much simple as possible. At this stage I'm going to implement the order engine, so meaning the whole code structure that allows to open positions in the given instrument.
As I already explained, any MA-based strategy is definetly not stable: always ends with an overall losing result, no matter what timeframe or instrument, but in the same time there are really good opportunities happening in particular conditions.
To simplify and improve my trade decisions, I need the maximum amount of informations and commands in the same chart so I found useful to sligthly modify a simple tool found in the Strategy API: the widget.
Chart widget
What triggered in my mind this idea is simple: since the full automation doesn't work (for this MA-based strategy), I will execute the trades manually, but I wa
Read article
Translate to English Show original
scramble avatar
scramble 19 Feb.

Actually, I had to remove the downloadable .java because I noticed there is something wrong with order execution. It works on strategy test, but does not work in real mode! Quite strange indeed.... will check out, and eventually post it on comments after I fix the issue :/

scramble avatar
scramble 19 Feb.

Of course.... if anyone has a suggestion will be much appreciated!! Thank you :)

scramble avatar
scramble 19 Feb.

Ok fixed. I thought it wasn't necessary to pass on te IOrder. I was following my idea based on previous strategy which was built in ITick.

scramble avatar
scramble 19 Feb.

I take the opportunity to modify some parts and implement the code to make it work better. I will probably finish before contest expiry date, so will publish everything on last article (just a quick review). Eventually if someone wants the code, I will put it available again. Thank you

orto leave comments
This is in continuation of previous article published on 4th February, where I exposed how the Linear Regression Slope indicator can be used to collect many informations in one single data outcome (indicator positive or negative) when used in m15 timeframe, with 96 time periods.
The second element

Before going to explain this step, I have to explain deeper the first one, showing a clear example of what happens in a daily chart and how I read it in the 15min timeframe.
In the following picture we see the EUR/AUD instrument in daily timeframe. Starting from the beginning of 2014, price was showing some attempts to keep rising and resume the previous uptrend, but as we see there was a strong reversal down with a full 2 days downward. This was due because of strong fundamental change, came near important resistance area.
Looking at this scenario in the 15m timeframe I have much more to say, see the chart:
When the new year was open, price immediatly came back down near 2013 close, showing a quick bounce reconquering the eMA65 and giving a further 50pips continuation to the upside (indeed strategy's purpose is to get maximum 40-45pips each trade). But the overall situation is
Read article
Translate to English Show original
Skif avatar
Skif 12 Feb.

Хорошее продолжение вашей первой статьи !!!

scramble avatar
scramble 12 Feb.

Thank you Skif :)

rokasltu avatar
rokasltu 17 Feb.

Very interesting. I try to do similar things but concentrating on long term run for now

orto leave comments


I have been observing for a while, one of my short term strategies to identify possible good entries or eventually 'emergency exits'. In the past I already explained it quite deeper with a series where I also shared a quick code in order to obtain the strategy to work in full automation: you can find all explanation about strategy concepts, codes and backtests following this link.
However, this kind of strategy creates a large amount of losing trades when price is stuck in major resistances and supports, indeed all MA-based strategies has the same limitation.
With this article series, I'm going to show all steps I made in recent months (long time spent watching strategy behavior), taking the opportunity to share some quick ideas which can be interesting for other members.
The first element
I have some firm beliefs about trading and one of them is the simplest ever: when there is a clean direction, everything works fine. See this chart:
If market was everyday like this, trading would make us billionaires in few months! Situations like this however, happens few times during one month and so I started wondering "what makes that situation different from another?".…
Read article
Translate to English Show original
Likerty avatar
Likerty 17 Feb.

welcome back to the contest:))

scramble avatar
scramble 11 Mar.


dinhero avatar
dinhero 16 Mar.

Hi, you article is good, the idea is good, but unfortunatly you are publishing only fragment of code without global variable, take some time to test the code, so just stop the reader to go the next article

scramble avatar
scramble 16 Mar.

hi dinhero, it's a series, not just 1 single article.but you will anyway need to read the whole articles to understand well the purpose of ony setting, why I did, and I use it. :) i paste the link in next comment

scramble avatar
scramble 16 Mar.

orto leave comments
After the first implementations exposed in previous article, I am now to show more important aspect involved in automating a strategy and as promised, I will show the results I obtained after last arrangements. Collecting data When planning a strategy - will it be manual or automated - one key step is to collect all data obtained from tests, to quickly compare all results. So I invested some time to setup this simple table, using a program easily found for free on the web:Using such a simple table, helps to understand if and how an arrangement really affects/or not a strategy, relatively to previous results. And it also helps me to save a lot of words! Previous test I finished last article showing the results obtained from the very first tests. After some days of study on strategy behavior, I came to the conclusion to reduce the stop loss and the take profit trying to stabilize the profitability by getting more profitable trades. Results were slightly better than previous, so I decided to take this as starting point. Here below you see the equity curve, obtained directly from Jforex visual tester:The curve shows nothing new respectively to the raw data, but helps to visually …
Read article
Translate to English Show original
scramble avatar
scramble 26 Apr.

yes efegen, the first picure is intentionally partial-obfuscate: all data are shown in the following paragraphs! tks :)

jlongo avatar
jlongo 29 Apr.

I'm a litle sceptical about using MA's with the current market flow, and obeying to too much parameters sooner or later we can't get the expected results. But is a good starting point and we are always learning :)

scramble avatar
scramble 29 Apr.

yes jose i know, MAs have some important problems. results obtained after last arrangements are very interesting anyway.. personally i didn't believe to reach such. let's see what forward tests will give! and yes... we are always learning! this strategy has been a great school for me! :) tks

AdrianWS avatar
AdrianWS 29 Apr.

good work and great to see that you are taking the time to learn to code, so useful in life! nice mini series you've got going, maybe next month try some really complicated multi indicator strategy :)

scramble avatar
scramble 29 Apr.

more likely i will crash my head while trying to understand how to restructure the open-position block (already a chair today was going...) :D eheh tks for your support :)

orto leave comments
PremiseI'm actually studying Java programming to improve my personal background. I started some time ago, but I had to postpone due to many difficulties and my knowledge is still at an elementary level, so in case you notice some mistakes on the code, please forgive me in advance. With this article I want to show how I automated a simple MA-based strategy. So I also take the opportunity to share it and to show my approach in detecting main factors and then all steps I considered while developing and testing the code.ToolsI decided to start coding the very first strategy I used because I have a good familiarity with all its good & bad aspects, and to use it in this article since gives a clear perception of the main aspects I'm presenting. However, the code can be modified to look for different MA periods in different timeframes and instruments.Instrument: EUR/USD;Timeframe: 15 Minutes;Indicators: EMA(14) & EMA(65);EssentialsThe strategy is simple and people could laugh thinking about it, while I really suggest to give it a deeper consideration.This is how the chart setup appears:The rule is clear: sell when green line (ema14) cross down the red one (ema65), buy when it cross up. But…
Read article
Translate to English Show original
scramble avatar
scramble 29 Apr.

tks @likery and @alifari! much appreciated :)

charmtrader avatar

wow! I am really impressed...great job!!!

charmtrader avatar


scramble avatar
scramble 29 Apr.

tks charm :) much appreciated!

scramble avatar

funny to have about 20-25fb likes, and see that they are not counted in total popularity.

orto leave comments
IntroductionIn my last article i write about how to save JForex values to files, expecting this month to write about saving this values on database. But i need to find and test a simple database that can be used by the most part of our readers without to much settings, configurations et all and i haven't finished it yet. Because of that, i write in this article about sending emails from inside of JForex in reaction to some values or events we want to get informed about them. The information about this subject provided on Dukascopy Wiki is somewhat incomplete and not works "out of the box", because almost all e-mail providers changed the way we can send e-mails using their servers. The example provided on wiki works if you have a insecure smtp (Simple Mail Transfer Protocol) server, and actually this is not used by almost all e-mail providers to avoid spam and unauthorized access. The possibility of sending e-mails inside JForex with events, values or alerts is a good tool for the ones who can't be always looking the charts but want to be alerted when something occurs and have access to their e-mail. With this article you can build your strategy to send e-mails with text only. At t…
Read article
Translate to English Show original
scramble avatar
scramble 30 Mar.

nothing to say! great inputs as always! thanks :)

doctortyby avatar
doctortyby 31 Mar.

keep it up jose

DiamondCutter avatar

good stuff

isobitis avatar
isobitis 1 Apr.

Good work. Works in windows.
However in Linux it throws an exception access denied ("" "" "resolve")

jlongo avatar
jlongo 1 Apr.

isobitis: it seems a problem with your Java permissions not allowing the socket utilization. See permissions policies.

orto leave comments
IntroductionIn first place i want to apologize the gap in time for my articles, but some personal problems prevented me from to have the time, the required concentration and patience to write them. In this article i try to talk about exporting JForex values we want to files on a textual manner for human readability or to CSV (comma separated values) to import them on other programs, for example Excel, Mathlab or any compatible program. Also you can import csv files directly on database. The ideia to this article came from my necessity to export some values for later analisys and use with other objectives without the need to be connected or doing tedious copy and paste of wanted values. In this article i will describe and exemplify all the process and obstacles faced during my learning process to achieve this. With this article you will be capable of extending it for other ideias you might have.The ideia...I need to loop by all available instruments to get some values from them. If we are doing this manually, that will be a tedious and time consuming task. For this article we assume we need the high, open, close, low, range and ATR values from monthly, weekly and daily periods of al…
Read article
Translate to English Show original
soon avatar
soon 20 Feb.

good luck

ecoplace avatar
ecoplace 21 Feb.

good luck , good articl more chance to you

fprophet avatar
fprophet 21 Feb.

I get errors trying to write to file on my Demo account:

with @RequiresFullAccess set:
Error creating or accessing the file: exportdata.txt (Access is denied)

without @RequiresFullAccess set:
Error creating or accessing the file: access denied ( exportdata.txt write)

I have tried various file path-names, without luck
Any thoughts on how to fix this?

fprophet avatar
fprophet 21 Feb.

ok - I figured out that the file has to already exist - this strategy code doesn't appear to be able to create the file ....

jlongo avatar
jlongo 22 Feb.

@fprophet; The strategy create a file if not exist (i tested in windows and linux)... may be any restriction on your filesystem that not allow the creation at the path (UAC of windows can be a reason). The directory reffered must exist. Anyway, to be sure you can change the path to your home directory or use IContext.getFilesDir() + "/filename.txt" to create the file at your home directory or at ".../JForex/Strategies/Files/". I hope that helps. Trade well. JL

orto leave comments