AlgoTraderAlgoTrader Documentation
Do not use it with a Live Trading Account and real Money! The strategy might lead to large losses. Even when modifying or extending the Strategy use caution before trading it live.
This example strategy shows how market indicator (Relative Strength Index in this case) can be used to generate buy or sell signals and act accordingly. There is no much focus on qualitative side, i.e. RSI signal is used in a simple, trivial way. However one can see how indicator is constructed, feed with market events and how trades can be sent based on the indicator's values.
There is a simple rule for position accumulation - it is allowed to sell only when there is no position or there is only long position, and it is allowed to buy only when being flat or short.
The main artifacts needed for the implementation of a new strategy are described in Chapter 4, Strategy Development.
The RSI strategy consist of the following main artifacts:
/src/main/java/ch/algotrader/strategy/rsi/RSIService.java
The strategy service class providing the main methods invoked by the application on certain events.
/src/main/resources/conf-rsi.properties
Config where the following parameters are specified:
period
- days to look back and calculate the RSI index,
buyThreshold
- index value, once value becomes below - treated as a buy signal,
sellThreshold
- index value, once value above - treated as a sell signal,
securityId
- id of the security to trade,
quantity
- order quantity.
To setup the strategy for back testing and live trading on a development workstation please execute the following steps:
If you have used the Section 2.1, “Windows Installer” to setup AlgoTrader, this project is already setup in the AlgoTrader IntelliJ IDEA and you can skip this step.
Download the Examples project zip file and unpack it in a directory of your choosing: https://www.algotrader.com/downloads/latest-examples
user name and password will be provided when signing up for an AlgoTrader license
If you need an older AlgoTrader version, login to our maven repository
(https://repo.algotrader.com/nexus)
and click on Browse
on the left and select code-general
.
Then select the AlgoTrader version you want and download:
Import/open the project rsi
To start the strategy in live trading mode on a development workstation please execute the following steps:
load the db-samples script into the MySQL database:
/algotrader-conf/src/main/resources/db-samples/mysql/mysql-data.sql
load the strategy specific script into the MySQL database:
/rsi/src/main/resources/db/mysql/mysql-data.sql
To start the Strategy please see the explanations in Chapter 3, Starting AlgoTrader.