I have changed the old series name to this new one, as at this moment it don't make too much sense to mantain it in my opinion... Also you need to check the new feature that Dukascopy Team created for us called "Visual JForex". This great tool will be a must for traders who want to create strategies but do not know about java programming as is almost a "drag and drop" tool. Several ways to interact with JForex are presented on my past articles, and now, on this first article of this new series, other way will be presented. Unfortunatly this type of strategy don't is possible to be created on Visual JForex yet.

As traders, with good or bad results, sometimes we want to exchange our trading activity, our fellings or market activity with others based "DEMO" or "LIVE" accounts (on Contest we have the contest pages). This "share" of activity can be just for fun and for business too. There exist several ways to inform our "social" or "business" network in real time about all aspects referred before, but that will be a tedious task as we need to do the input manualy or create "tedious" reports made by hand. What if we can share almost all we can imagine automaticaly to our public or private "network" ? Twitter is one of this networks, that consist in a simpler way in a exchange of simple messages with our "contacts" or followers called "tweets" in real time. This simple messages or "tweets" are like sms messages we can send to the Twitter network and they can be viewed by all public followers or by private (previousely authorized) followers. In this article i will explain a way to make JForex to send this simple messages with JForex events to this network automatically. More can be done, but in this article we only explore this possibility, and is a starting point to expand to the other possibilities if you have some interess on that.


  • Have at least one Twitter account. If not, just go to the Twitter page and create one.
  • You need to configure your Twitter account to allow the comunication of our strategy with Twitter services to send messages in our behalf as we do manually, but more about this will be described below.
  • We can do the comunication with Twitter with integrated java libraries, but that will be a tedious and time consuming task. In our case we will use a external library where all this tedious work is done for us. You will need to download this library and do some things i will explain below.
  • and that's all.

Configuring Twitter account

To avoid some spam bots on Twitter network, Twitter has created a "protocol" that programs developed by external companies or persons like you and me can use to comunicate with Twitter services without the need to do repetitive logins manually. Describing in a simple way, we create on our account "credentials" for our program to do our login and for the program itself be recognized by Twitter services. To do this we need to access the following page of Twitter app developers and login with our account username and password.

Image 1 - Login page of Twitter developers.

After the login we need to create our "application" as shown on image below. In this case i have created one before. Just click on "Create a new application".

Image 2 - Initial step to get the needed "credentials".

On the next step, you need to fill some fields with your "application" details. The name and description is prety simple as the fields say everything needed. The required field "Website" can be something you want as "" unless you plan to distribute your made strategy as .jfx for other persons. In this case you must use a real domain as the person that will be using the strategy needs to validate the trategy to his account and this information is shown. The next field "Callback URL" you don't need to put anything unless the case i referred before for some special cases. Next you need to check the rules agreement, fill the captcha and hit "Create your Twitter application" as shown bellow.

Image 3: Application basic information fields on Twitter page of application creation.

I have created a application called "my strategy" on description i used "strategy communication" and on website i placed "". After this we are redirected to a page with some tabs. The start tab is "Details", but before doing anything else, we need to go to the tab "Settings" as on image below.

Image 4: "Settings" tab. Here we need to set some rights to our application as explained below.

On this tab we need to set the correct application type to "Read and Write" or to "Read, Write and Access direct messages". By default our application settings on "Application Type" is to "Read only" and this is enought for applications that only reads "tweets" from our Twitter account. But we need to send "tweets" and for that we need "Read and Write" option checked at least. If you develop a strategy with the possibility to send "Direct messages" ("tweets" sent directly to one person like a "private message") you need to check the last option to allow this. But for our strategy "Read and Write" is enought as we don't explore this possibility on our strategy, but this way you know of. You can also fill the "Organization" fields if applicable. After we choosed the right settings we need to click on "Update this Twitter application settings" (this is IMPORTANT!). On next step we go to "Details" tab as we can see on the image bellow.

Image 5: We are almost done... We need to click "Create my access token".

On the "Details" tab now we can click on "Create my access token" to generate the "credentials" for our use on our strategy. On the next step (the final one), we need to go to the "OAuth" tab to get our credentials as shown on the image below.

Image 6: On "OAuth" tab now we can get all needed credentials. Also we have the possibility to reset our personal keys (not application keys) and delete the application submission on each of the correspondent tabs.

On "Oauth" tab we get all needed "keys" to place on our strategy to be able to interact with Twitter services. The "Consumer key" is something like the "User Login", "Consumer secret" is like "User password", "Access token" is like "Application login" and "Access token secret" is like "Application password".


Never show as is in textual maner the "secret" fields !!! (in my opinion also the other fields) as with them someone can use this keys to interact with Twitter services as if you !!! Also never distribute source code with them !!! Delete them before doing that. If you distribute only the .jfx strategy don't is a problem as all information is encripted.

The "keys" presented in this article are deleted.

And for Twitter configuration steps was all we need.

Download and prepare the needed library

To make our life easiest, we will use a external library inside our strategy to interact with Twitter services. One of the best and better know i know of is Twitter4J or "Twitter for java". To download this free library you need to go at Twitter4J site and download it. You can go directly to the site clicking here. Go to download section and download the last version (at the moment of writing this article is 3.0.3 version).

Image 7: Twitter4J site. If you use Netbeans or Eclipse IDE, you can add the Twitter4J library to your JForex API maven project following the instructions below the download section on this page.

After the download you need to decompress the file to a place of your choice on your system. The important file for the strategy is on "lib" folder of the directory structure of the zip file and is "twitter4j-core-3.0.3.jar". There are other libraries but for this case not needed. With this libraries you can make a full java Twitter client with almost all funcionality provided by Twitter. You need to remember the path and name to this library and will be something like "<your chosed place full path>/lib/twitter4j-core-3.0.3.jar".

All needed prerequesites are done, and now we can build our Twitter "friendly" strategy... But as usual i get "space" problems on articles and i need to separate this theme on two articles to be possible to complete it on a understandable manner. I will try to post it as soon as possible, where we finaly bring the strategy to the light and also some bonus... Stay tunned, and if you have some suggestions feel free to do so, i will try to present or talk about them on next article.

Trade well.


الترجمة الى الانجليزية اظهار الاصلي