<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">IIM</journal-id><journal-title-group><journal-title>Intelligent Information Management</journal-title></journal-title-group><issn pub-type="epub">2160-5912</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/iim.2017.96012</article-id><article-id pub-id-type="publisher-id">IIM-80106</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Computer Science&amp;Communications</subject></subj-group></article-categories><title-group><article-title>
 
 
  Predicting Optimal Trading Actions Using a Genetic Algorithm and Ensemble Method
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Kazuma</surname><given-names>Kuroda</given-names></name><xref ref-type="aff" rid="aff1"><sub>1</sub></xref><xref ref-type="corresp" rid="cor1"><sup>*</sup></xref></contrib></contrib-group><aff id="aff1"><label>1</label><addr-line>Data Marketing Laboratory, Tokyo, Japan</addr-line></aff><author-notes><corresp id="cor1">* E-mail:<email>mokuzenshingo@me.com</email></corresp></author-notes><pub-date pub-type="epub"><day>01</day><month>11</month><year>2017</year></pub-date><volume>09</volume><issue>06</issue><fpage>229</fpage><lpage>235</lpage><history><date date-type="received"><day>23,</day>	<month>September</month>	<year>2017</year></date><date date-type="rev-recd"><day>29,</day>	<month>October</month>	<year>2017</year>	</date><date date-type="accepted"><day>1,</day>	<month>November</month>	<year>2017</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  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.
 
</p></abstract><kwd-group><kwd>Artificial Intelligence</kwd><kwd> Ensemble Learning</kwd><kwd> Genetic Algorithms</kwd><kwd> Neural Networks</kwd><kwd> FOREX</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>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.</p><p>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 [<xref ref-type="bibr" rid="scirp.80106-ref1">1</xref>] [<xref ref-type="bibr" rid="scirp.80106-ref2">2</xref>] . Generally, ANNs are trained using the back-propagation algorithm. However, the back-propagation algorithm may become stuck in a local minimum. Therefore, previous studies [<xref ref-type="bibr" rid="scirp.80106-ref3">3</xref>] [<xref ref-type="bibr" rid="scirp.80106-ref4">4</xref>] have used genetic algorithms (GA) to avoid this problem because such algorithms can search global optimum solutions.</p><p>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) [<xref ref-type="bibr" rid="scirp.80106-ref5">5</xref>] [<xref ref-type="bibr" rid="scirp.80106-ref6">6</xref>] . In this context, a GA can provide a variety of agents with different trading strategies.</p><p>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 [<xref ref-type="bibr" rid="scirp.80106-ref3">3</xref>] demonstrated that the average performance of different agents outperformed the best agent in the training data. However, from an asset efficiency perspective, this approach is impractical because it must hold many trading positions.</p><p>Ensemble methods combine the outputs of base models using a majority vote mechanism to create a single output [<xref ref-type="bibr" rid="scirp.80106-ref7">7</xref>] . Many studies have demonstrated that ensemble methods show superior performance for a variety of problems, such as image classification [<xref ref-type="bibr" rid="scirp.80106-ref8">8</xref>] and facial recognition [<xref ref-type="bibr" rid="scirp.80106-ref9">9</xref>] .</p><p>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.</p><p>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.</p></sec><sec id="s2"><title>2. Algorithm to Predict Optimum Actions</title><p>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.</p><sec id="s2_1"><title>2.1. Construction of Base Models</title><p>Trading agents are constructed by the training architecture shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>. Here, each agent comprises two modules, i.e., signal and strategy modules. The signal module uses price data as input and generates a signal (Long, Short, or Do-nothing) evaluated market condition as output, which we refer to as the market signal. The strategy module determines the trading action from the market signal, the trading position, and past prices. The GA calculates the fitness</p><p>according to the trading action of the agent and evolves the agents using this fitness value.</p><p>1) Signal Module</p><p>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.</p><p>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 [<xref ref-type="bibr" rid="scirp.80106-ref10">10</xref>] and is given by the following equation:</p><p>RSI = 100 − ( 100 / 1 + RS ) ,</p><p>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 [<xref ref-type="bibr" rid="scirp.80106-ref11">11</xref>] . Note that an increasing ADX value represents the trend strength. To quantify the trend strength, we use diffADX, which is given by the following equation:</p><p>diffADX t = ADX t − ADX t − 1 ,</p><p>where diffADX<sub>t</sub> is the trend strength for time step t and ADX<sub>t</sub> 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 [<xref ref-type="bibr" rid="scirp.80106-ref11">11</xref>] . DM+ represents an upward trend direction, and DM− represents a downward trend direction. For simplicity, we use uniDMI, which is given as follows:</p><p>uniDMI t = DM + t −   DM − t ,</p><p>where uniDMI<sub>t</sub> is the trend direction for time step t, DM+<sub>t</sub> is the DM+ for time step t, and DM−<sub>t</sub> is the DM− for time step t.</p><p>2) Strategy Module</p><p>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:</p><p>Close-Out = currentHigh &gt; positionClose + ω 1 &#215; Volatility ;</p><p>currentLow &lt; positionClose − ω 2 &#215; Volatility ;</p><p>The market signal is Short</p><p>Do-Nothing = otherwise</p><p>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. ω<sub>1</sub> and ω<sub>2</sub> 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:</p><p>Close-Out = currentLow &lt; positionClose − ω 3 &#215; Volatility ;</p><p>currentHigh &gt; positionClose + ω 4 &#215; Volatility ;</p><p>The market signal is Long</p><p>Do-Nothing = otherwise</p><p>where ω<sub>3</sub> and ω<sub>4</sub> are parameters used to optimize the settlement width.</p><p>3) Genetic Algorithm</p><p>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.</p><p>1) Randomly initialize a population of agents.</p><p>2) Provide training data to each agent and obtain the trading action for each time step.</p><p>3) Trade according to the trading action and observe the returns of each time step.</p><p>4) Calculate the fitness from the returns of each time step at the end of the training data.</p><p>5) Evaluate each agent in the population according to their fitness and select parents for new agents.</p><p>6) Create new agents based on the selected parents using crossover and mutation operators.</p><p>7) If the termination condition is satisfied, this process is terminated; otherwise, return to step 2.</p></sec><sec id="s2_2"><title>2.2. Combined Base Models</title><p>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.</p></sec></sec><sec id="s3"><title>3. Experiment and Results</title><p>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.</p><sec id="s3_1"><title>3.1. Data Collection</title><p>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 [<xref ref-type="bibr" rid="scirp.80106-ref12">12</xref>] . The validation data comprised 6097 samples for the period 01/01/2015 9:00 pm to 31/12/2015 10:00 pm. The test data comprised 9263 samples for the period 04/01/2016 12:00 am to 01/07/2017 1:00 am.</p></sec><sec id="s3_2"><title>3.2. Results</title><p>The results of training and validation for each generation are shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>. As can be seen, a peak was reached near 200 generations for both the training and validation data. In addition, the results were stable after 200 generations. After 200 generations, the best generation was generation 437 on the validation data, and this generation was chosen for testing.</p><p>The statistics of the tested agents are summarized in <xref ref-type="table" rid="table1">Table 1</xref>, and the cumulative returns are shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>. In <xref ref-type="table" rid="table1">Table 1</xref>, the Total Return column is the sum of all returns of agents, the Win rate column is the percentage of transactions with positive returns, and the Trades column is the number of closed positions. The results show that the performance of the ensemble approach is superior to the approach using the average performance of many agents.</p></sec></sec><sec id="s4"><title>4. Conclusion</title><p>We have designed the ensemble approach that combines trading agents. In the</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1">Table 1</xref></label><caption><title> Statistics of tested agents (Ensemble: results of combined agents; Average: mean value of tested agents)</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >Total return</th><th align="center" valign="middle" >Win rate</th><th align="center" valign="middle" >Trades</th></tr></thead><tr><td align="center" valign="middle" >Ensemble</td><td align="center" valign="middle" >25.0</td><td align="center" valign="middle" >54.7%</td><td align="center" valign="middle" >2331</td></tr><tr><td align="center" valign="middle" >Average</td><td align="center" valign="middle" >13.8</td><td align="center" valign="middle" >54.1%</td><td align="center" valign="middle" >1880</td></tr></tbody></table></table-wrap><p>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.</p></sec><sec id="s5"><title>Cite this paper</title><p>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</p></sec></body><back><ref-list><title>References</title><ref id="scirp.80106-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Kamruzzaman, J. and Sarker, R. (2004) ANN-Based Forecasting of Foreign Currency Exchange Rates. Neural Information Processing, 3, 49-58.</mixed-citation></ref><ref id="scirp.80106-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Vincenzo, P., Vitoantonio, B. and Michele, A. (2011) An Artificial Neural Network Model to Forecast Exchange Rates. Journal of Intelligent Learning Systems and Applications, 3, 57-69. https://doi.org/10.4236/jilsa.2011.32008</mixed-citation></ref><ref id="scirp.80106-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Yaman, A., Stephen, L. and Izidor, G. (2014) Evolutionary Algorithm Based Approach for Modeling Autonomously Trading Agents. Intelligent Information Management, 6, 45-54. https://doi.org/10.4236/iim.2014.62007</mixed-citation></ref><ref id="scirp.80106-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Kenneth, O.S. and Risto, M. (2004) Competitive Coevolution through Evolutionary Complexification. Journal of Artificial Intelligence Research, 21, 63-100.</mixed-citation></ref><ref id="scirp.80106-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Hirabayashi, A., Claus, A. and Iba, H. (2009) Optimization of the Trading Rule in Foreign Exchange Using Genetic Algorithm. GECCO ‘09 Proceedings of the 11th Annual Conference on Genetic and Evolutionary Computation, Montreal, 8-12 July 2009, 1529-1536. https://doi.org/10.1145/1569901.1570106</mixed-citation></ref><ref id="scirp.80106-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Ibrahim, A.E.M. (2014) Evolutionary Approach to Forex Expert Advisor Generation. Intelligent Information Management, 6, 129-141.https://doi.org/10.4236/iim.2014.63014</mixed-citation></ref><ref id="scirp.80106-ref7"><label>7</label><mixed-citation publication-type="other" xlink:type="simple">Witten, I. and Frank, E. (2005) Data Mining: Practical Machine Learning Tools and Techniques. 2nd Edition, Morgan Kaufmann, San Francisco.</mixed-citation></ref><ref id="scirp.80106-ref8"><label>8</label><mixed-citation publication-type="other" xlink:type="simple">Silwattananusarn, T., Kanarkard, W. and Tuamsuk, K. (2016) Enhanced Classification Accuracy for Cardiotocogram Data with Ensemble Feature Selection and Classifier Ensemble. Journal of Computer and Communications, 4, 20-35.https://doi.org/10.4236/jcc.2016.44003</mixed-citation></ref><ref id="scirp.80106-ref9"><label>9</label><mixed-citation publication-type="other" xlink:type="simple">El Khiyari, H. and Wechsler, H. (2016) Face Recognition across Time Lapse Using Convolutional Neural Networks. Journal of Information Security, 7, 141-151.https://doi.org/10.4236/jis.2016.73010</mixed-citation></ref><ref id="scirp.80106-ref10"><label>10</label><mixed-citation publication-type="other" xlink:type="simple">Murphy, Jr. J.E. (1994) Stock Market Probability: Using Statistics to Predict and Optimize Investment Outcomes. Revised Edition, Irwin.</mixed-citation></ref><ref id="scirp.80106-ref11"><label>11</label><mixed-citation publication-type="other" xlink:type="simple">Sheimo, M.D. (1998) Cashing in on the Dow: Using Dow Theory to Trade and Determine Trends in Today’s Markets. CRC Press, Boca Raton.</mixed-citation></ref><ref id="scirp.80106-ref12"><label>12</label><mixed-citation publication-type="other" xlink:type="simple">Badarch, T., Shu, L. and Iba, H. (2011) A Trading Method in FX Using Evolutionary Algorithms: Extensions Based on Reverse Trend and Settlement Timing. GECCO ‘11 Proceedings of the 13th Annual Conference Companion on Genetic and Evolutionary Computation, Dublin, 12-16 July 2011, 139-140.</mixed-citation></ref></ref-list></back></article>