Machine learning has been applied to the foreign exchange market for algorithmic trading. However, the selection of trading algorithms is a difficult problem. In this work, an approach that combines trading agents is designed. In the proposed approach, an artificial neural network is used to predict the optimum actions of each agent for USD/JPY currency pairs. The agents are trained using a genetic algorithm and are then combined using an ensemble method. We compare the performance of the combined agent to the average performance of many agents. Simulation results show that the total return is better when the combined agent is used.
The Foreign Exchange Market (FOREX) has become complex due to the introduction of floating exchange rates and the expansion of global trading markets. Due to this complexity, predicting future prices and designing trading algorithms have been considered as challenging problems. Recently, researchers have started to design trading algorithms.
Artificial neural networks (ANN) are often used in prediction tasks and system modeling. ANNs use nonlinear functions; thus, they are robust in complex and dynamic environments such as the FOREX [
GAs are heuristic algorithms based on Darwinian evolution and are frequently used to find optimum solutions. In the case of a trading algorithm, GAs have been used to determine the optimum trading model parameters, such as the connection weights of the ANN, feature selection, and the settlement width (difference between the closing price of the position and the price at the time of settlement) [
Here, the problem lies with the selection of the agent. Although the best agent with training data is obtained, the results are often incorrect with test data. A previous study [
Ensemble methods combine the outputs of base models using a majority vote mechanism to create a single output [
In this study, we employed an ensemble method to combine trading agents. In the proposed method, we begin by constructing multiple agents. Here, an ANN and conditional equations are used in the agents’ decision mechanisms. A GA is used to train the connection weights of the networks, the period used to calculate technical indicators, and the settlement width. Next, we combine the output of the trained agents using a majority vote mechanism. We performed tests to determine whether the combined agent outperforms the average performance of many agents.
The remainder of this paper is organized as follows. A detailed description of the algorithm used to predict optimum trading actions is given in Section 2, and Section 3 discusses the performance of the proposed approach. Conclusions are given in Section 4.
The procedure to obtain the combined agent is divided into two steps. The first step is construction of the base models, and the second step is combining the outputs of the base models. In this section, we describe these processes in detail.
Trading agents are constructed by the training architecture shown in
according to the trading action of the agent and evolves the agents using this fitness value.
1) Signal Module
The ANN is used to evaluate market conditions and generate the market signal, and the network comprises four input neurons. The inputs to these neurons are three technical indicators and bias. The networks contain six hidden units, where the activation function of all hidden units is a sigmoid function. The output neurons of the networks consist of three, each neurons corresponding to the market signal. The GA optimizes the connection weights from the input layer to the output layer.
The following three technical indicators, which are calculated from the price data, are used as input to the networks. In addition, the GA optimizes the period used to calculate the technical indicators. The relative strength indicator (RSI) is used to determine when the market is over-bought or over-sold [
RSI = 100 − ( 100 / 1 + RS ) ,
where RS is the average gain over n hours divided by the average loss over n hours. The average directional index (ADX) describes when a market is trending without considering trend direction [
diffADX t = ADX t − ADX t − 1 ,
where diffADXt is the trend strength for time step t and ADXt is the ADX for time step t. The directional movement index comprises two lines, i.e., plus directional movement (DM+) and minus directional movement (DM−), and defines the trend direction [
uniDMI t = DM + t − DM − t ,
where uniDMIt is the trend direction for time step t, DM+t is the DM+ for time step t, and DM−t is the DM− for time step t.
2) Strategy Module
The strategy module determines the trading action according to the following rules. Note that the trading action of time step t is determined by the data point of time step t − 1. If an agent does not hold a trading position, then the agent takes a position according to the market signal. If an agent holds a long position, then the trading action is determined using the following rules:
Close-Out = currentHigh > positionClose + ω 1 × Volatility ;
currentLow < positionClose − ω 2 × Volatility ;
The market signal is Short
Do-Nothing = otherwise
where current High and current Low are the high and low prices among the data points, respectively, position Close is the closing price of the position, and Volatility is the standard deviation of the closing price over the last seven hours. ω1 and ω2 are parameters used to optimize the settlement width. If an agent holds a short position, then the trading action is determined using the following rules:
Close-Out = currentLow < positionClose − ω 3 × Volatility ;
currentHigh > positionClose + ω 4 × Volatility ;
The market signal is Long
Do-Nothing = otherwise
where ω3 and ω4 are parameters used to optimize the settlement width.
3) Genetic Algorithm
The GA evaluates the fitness and evolves the trading agents according to the fitness value. Here, the fitness is the total return calculated using raw prices. As mentioned previously, the GA evolves the connection weights of the ANN, the period used to calculate technical indicators, and the settlement width. The evolutionary process is as follows.
1) Randomly initialize a population of agents.
2) Provide training data to each agent and obtain the trading action for each time step.
3) Trade according to the trading action and observe the returns of each time step.
4) Calculate the fitness from the returns of each time step at the end of the training data.
5) Evaluate each agent in the population according to their fitness and select parents for new agents.
6) Create new agents based on the selected parents using crossover and mutation operators.
7) If the termination condition is satisfied, this process is terminated; otherwise, return to step 2.
The outputs of the trained agents are combined by majority vote to create a single output. For each time step, the trained agents generate trading actions on the new data point and the closing price of the position as input. Then, the most frequently output trading actions are taken as the output of the combined agent.
In this section, we apply the proposed ensemble approach to USD/JPY currency pairs to test whether the combined agent outperforms the average performance of many agents. Here, the return is JPY-based. The training algorithm was run 500 times on the training data, and the resulting best agents for each generation were added to the agent pool. We used a population with 500 individuals over 500 generations. Then, to address the overtraining problem, the result obtained by applying validation data to the agent in the agent pool was used to select the generation to be tested. We obtained 500 agents as a result. Those agents were then used to compare the performance of the combined agent and the average of the agents on the test data.
The agents were trained, validated, and tested using USD/JPY hourly data. Each data point included the opening and closing price and the high and low price for each hour interval. The original training data consisted of 30115 samples for the period 03/01/2010 9:00 pm to 31/12/2014 9:00 pm. Training was performed with the training data, which was the original training data inverted and added [
The results of training and validation for each generation are shown in
The statistics of the tested agents are summarized in
We have designed the ensemble approach that combines trading agents. In the
Total return | Win rate | Trades | |
---|---|---|---|
Ensemble | 25.0 | 54.7% | 2331 |
Average | 13.8 | 54.1% | 1880 |
proposed method, an ANN is used to predict the optimum actions of trading agents for USD/JPY currency pairs. These agents are trained using a GA and then are combined using an ensemble method. We performed tests to determine whether the combined agent outperforms the average performance of many agents. The results show that the total return is better when the ensemble method is used. In addition, the ensemble approach takes only a single position; thus, it is more asset efficient than approaches that use the average performance of many agents. In conclusion, the proposed ensemble approach works as an alternative to using the average performance of many agents.
Kuroda, K. (2017) Predicting Optimal Trading Actions Using a Genetic Algorithm and Ensemble Method. Intelligent Information Management, 9, 229-235. https://doi.org/10.4236/iim.2017.96012