In this article we discuss feature generation for a long/short forex strategy. This strategy can be used in conjunction with long/short equity strategies for diversification purposes.
Forex is an important asset class that can provide effective diversification, as shown in a recent article where we discussed a trend-following forex strategy.
In another article we discussed feature engineering for a long/short equity strategy. The feature engineering task was performed by DLPAL software.
DLPAL software offers unique capability of calculating historical values of four indicators (also called features, attributes or predictors in machine learning) using the historical data for each security in a universe of any size. The frequency of the data is usually daily but it can also be of any time frame. Long/short signals are generated based on the values of the four indicators, PLong, PShort, Pdelta and S, or any combination of them. More details about these indicators can be found in the program manual.
The historical data files of the indicators can be imported in a backtesting platform for developing and testing long/short strategies. In this article we consider five major currency pairs.
Historical file generation
The historical indicator files were generated by DLPAL PRO. However, the same files can be generated by DLPAL LS, an institutional grade version of DLPAL software
The DLPAL software takes the original historical data files of the currency pairs and creates a new set of files with extension .pih that include the indicator values for each instance (row). The feature generation starts on 01/02/2012 with the historical data files extending back to 01/02/2001. This data history is required for calculating the features.
Below is the DLPAL PRO workspace for generating the features. The history length is set to 1625 bars because we want to generate feature history from 01/02/2012 to 03/31/2017. We selected normal features, 1% profit target and stop loss and no detrend option.
Below is an example of how a .pih file looks like:
The .pih files are then imported in a trading platform. Here we use Amibroker because it offers advanced portfolio backtesting and analysis capabilities in addition to the ease of importing historical data with additional fields. The four indicators are imported as follows: PLong is assigned to Volume, PShort is assigned to Open Interest, Pdelta is assigned to AUX1 and S to AUX2. A typical chart of a currency pair with the features is shown below.
Strategy type: Long/short forex
Universe: EUR/USD, AUD/USD, GBP/USD, USD/CAN, USD/CHF
Backtest period: 01/02/2012 – 03/31/2017
Maximum open positions: 5
Position entry and exit: Open of next bar
Strategy initial capital: $100,000
Position size: One standard lot per currency pair, fixed
Signals: long and short (stop and reverse)
Although there are several options, including the use of machine learning classifiers in the case of more advanced models, here we use a model with the AUX1 feature as follows.
Buy = Cover = AUX1 > 5
Short = Sell = AUX1 < -5
It may be seen that the strategy is always invested in all five currency pairs, long or short, depending on the feature values.
Note that the above performance is for $100K initial capital. If the initial capital is $50K, for example, CAGR increases to 16.6% and maximum drawdown rises to 32%.
Below are the equity and underwater equity curves (Click on images to enlarge.)
Obviously, a lot more work is required to develop a final strategy, especially of institutional grade. This article only covered the basic concept. However, the initial results look promising.
You can download a demo of DLPAL and DLPAL PRO here. For more articles about DLPAL and DLPAL PRO click here. Note that in the Basic and PRO version personal license there are certain limitations when creating historical indicator files.
We have also just announced DLPAL LS, a version of the program specifically designed for hedge funds. More details can be found here.
If you have any questions or comments, happy to connect on Twitter: @priceactionlab
Charts were created with Amibroker – advanced charting and technical analysis software. http://www.amibroker.com