JForex API & Robot Creation
Dipl.-Inf. Bernhard Schicht
29.01.2018
Definitions
What is it all about?
1
STEP
Intro
Forex
Forex (FX) is the market in which currencies are traded. The forex market is the largest, most liquid market in the world, with average traded values that can be trillions of dollars per day. It includes all of the currencies in the world.
From
https://www.investopedia.com
Daily Trading Volume
5 T/d
open 5/24
There is no central marketplace for currency exchange; trade is conducted over the counter. The forex market is open 24 hours a day, five days a week, except for holidays, and currencies are traded worldwide among the major financial center
From
https://www.investopedia.com/terms/f/forex.asp
Robots
Morton Glantz, Robert Kissell. Multi-Asset Risk Modeling: Techniques for a Global Economy in an Electronic and Algorithmic Trading Era. Academic Press, Dec 3, 2013, p. 258.
JForex platform
Swiss Broker Dukascopy Bank
JForex
Bank based in Geneva, Switzerland.
They developed the JForex platform
JForex API
consists of
- Strategy API
- Robot development
- Creation of trading tools
- Indicator API
- Indicator development only
Strategy API
- submitting and managing various kinds of orders,
- using built-in indicators
- working with historical data,
- plotting graphical objects and indicators on a chart,
- logging information to console, extending user interface and accessing account information.
IStrategy interface (1)
- onStart is called upon at the strategy start. One would normally initialize variables held by IContext , subscribe to feeds (e.g. custom period, range bars, renko bricks, etc.) and do other strategy setup operations.
- onTick is called upon at every tick of every instrument that the application is subscribed on. When working with particular instruments such as these one should consider tick filtering. This method receives the latest ITick of the corresponding instrument from which the user can retrieve the latest BID and ASK prices and volumes.
- onBar is called upon when a bar is finished for every basic period and instrument that application is subscribed on. When working with particular instruments and periods one should consider this bar filtering. This method receives the latest BID and ASK IBar of the particular Instrument and Period from which the user can retrieve the open, close, high and low prices, as well as the volume.
IStrategy interface (2)
- onMessage is called upon when a new message is received. This method receives an IMessage whenever the state of any order changes, thus allowing the user to manage the order state.
- onAccount is called upon when an the account info update is received.
- onStop is called upon before a strategy is stopped. Depending on the strategy logic, one would consider closing all active orders, removing created chart objects, disposing any custom GUI objects, etc.
STEP
2
Create a trading setup
- KISS
- Visual "entry" test on chart
- Use statistics
- Finally create a setup description
Setup
Idea
Rising ---------- candle stick ----------- Falling
Candle stick
Setup description
- Candle stick period defined
- Always analysed in candles
- All must be in same direction, falling or rising
- There is a min. body size and a max. body size
- When a pattern is found, we wait for a reversal of x pips
- Our trade is directed into the same direction as our pattern, falling or rising
- A maximum of y seconds is waited until the market touches the entry
- Only one trade at the same time is allowed
- We allow pattern recognition from 1600-2000 UTC only = trading session
- We can set the initial trading volume, stop loss and take profit
- Ability to increase trading volume after profit trade
- The first trade made during the trading session will have the initial volume
Example going short
looking for 3 candles,
requested body size between 0.5 and 1.0 pips to go short, limit entry is 3 pips higher than close of 3rd candle.
STEP
3
Now it is time for implementation
Implemen-
tation
STEP
Compilation, Tests and Optimization
4
Tests
STEP
Ready to launch our strategy on the Dukascopy server
5
Launch
STEP
- Quick resources guide
- Pros and cons of algorithmic trading
- Questions
6
Q&A
Resources
- https://www.dukascopy.com/client/javadoc/
- https://www.dukascopy.com/swiss/english/forex/api/jforex_api/
- https://www.dukascopy.com/wiki/
Thank you!
Bernhard Schicht
Stash GmbH
Sollner Str. 71 a
81479 Munich/Germany
Web: http://www.stash.de
Fon: +49 172 46 28 038
E-Mail: trading@stash.de