A Time Series Model Based on Deep Learning and Integrated Indicator Selection Method for Forecasting Stock Prices and Evaluating Trading Proﬁts

: A stock forecasting and trading system is a complex information system because a stock trading system needs to be analyzed and modeled using data science, machine learning, and artificial intelligence. Previous time series models have been widely used to forecast stock prices, but due to several shortcomings, these models cannot apply all available information to make a forecast. The relationship between stock prices and related factors is nonlinear and involves nonstationary fluctuations, and accurately forecasting stock prices is not an easy task. Therefore, this study used support vector machines (linear and radial basis functions), gene expression programming, multilayer perceptron regression, and generalized regression neural networks to calculate the importance of indicators. We then integrated the five indicator selection methods to find the key indicators. Next, we used long short-term memory (LSTM) and gated recurrent units (GRU) to build time series models for forecasting stock prices and compare them with the listing models. To evaluate the effectiveness of the proposed model, we collected six different stock market data from 2011 to 2019 to evaluate their forecast performance based on RMSE and MAPE metrics. It is worth mentioning that this study proposes two trading policies to evaluate trading profits and compare them with the listing methods, and their profits are pretty good to investors. After the experiments, the proposed time series model (GRU/LSTM combined with the selected key indicators) exhibits better forecast ability in fluctuating and non-fluctuating environments than the listing models, thus presenting an effective reference for stakeholders.


Introduction
High-dimensional data lead to an increase in the complexity of interrelated components in stock trading systems, which in turn lead to the creation of complex information systems. Complex stock trading systems require understanding and modeling, and the role of data science, machine learning, and artificial intelligence in modeling stock trading. Therefore, stock forecasting and trading systems are complex information systems. Stock price forecasting is a very important issue in the financial field because accurate forecasting will bring great potential benefits to investors. Financial experts are interested in forecasting behavior models of stock prices, and investors are also interested in these patterns. In an economically frustrated and complicated investment environment, there is an urgent need to develop a tool that can reflect the future price index. For example, developing price forecasts for different stock markets and providing advice to decision makers can make investors profitable. However, time series forecasting in financial markets is considered one of the most challenging tasks in modern time series forecasting [1]. Many economists adopt the efficient market hypothesis (EMH), which believes that price changes are independent of the past and follow random walks [2]. Although there are many arguments for EMH, 2 of 31 Abu-Mostafa and Atiya [3] argued that financial markets are somewhat predictable. Although the stock fluctuations are nonlinear and non-stationary, they will cause unexpected results. Currently, the powerful computing and problem-solving capabilities of artificial intelligence can take into account relevant available information, including past trading volume and prices, to forecast stock prices. Therefore, many researchers have established and are working on effective and accurate forecast models based on artificial intelligence. There are two methods commonly used to forecast stock prices: fundamental analysis and technical indicators. The former involves macroeconomic indicators and uses them as a general assessment; however, it is difficult to apply them to a complex stock market environment. The latter obtains new signals by inputting prices and selecting technical indicators to achieve the purpose of forecasting. This study will discuss and use technical indicators to explore forecasts of stock prices.
Today, there are many tools for forecasting stock prices, but forecasting stock prices is still extremely challenging. Since it involves obtaining stock market-related data, the original data often face high-dimensional problems; hence, forecasting stock prices without data preprocessing may lead to higher computational costs or overtraining. To solve this problem, most studies have used important variables based on the variable selection method as input variables to build forecast models for reducing the dimensionality of the original data [4][5][6][7][8][9][10]. The dimensionality reduction method reduces the dimensionality of the data to decrease the resources required for calculation and improve the performance of the model while retaining most of the information from the original data. Nobre and Neves [11] applied principal component analysis to reduce high-dimensional data and used the discrete wavelet transform to model the data after dimensionality reduction, and their profit was better than that of the buy and hold strategy. Chen et al. [12] used the Granger causality test to determine whether a time series has a positive impact on the forecast of another time series because this test method provides meaning to the causality of the time series. Based on the statistical test, their forecast of the stock index in the multilayer perceptron regression had a good performance.
There are many time series forecast models for stock market forecasting. Models for forecasting stock prices can be divided into two categories: statistical and machine learning models. Statistical models usually assume that stock price movements are generated linearly and follow a normal distribution, but the actual stock price movement is often not an assumption of normal distribution and linear relation. Time series statistical models include an autoregressive integrated moving average (ARIMA), generalized autoregressive conditional heteroskedasticity [13], etc. One shortcoming of the traditional statistical time series model is that the data sequence needs to be stationary, but this phenomenon is inconsistent with the non-stationarity and non-linearity of stock price fluctuations. In recent years, deep learning (DL) has been a hot topic in data science, and its technologies have been successfully applied in the financial field. DL has the advantages of not requiring prior feature extraction and automatically extracting features based on deeper and more complex networks. Hence, it has more powerful computing capabilities to build models. DL technologies include fuzzy neural networks, artificial neural networks, long short-term memory (LSTM), and gated recurrent unit (GRU), and their algorithms can construct many complex forecast models based on experience with no restrictive or statistical assumptions. Therefore, this study compared DL technology with listing methods for forecasting six different stock indexes.
How can decision makers trust the recommendations of deep learning and justify them [14]? From previous studies, we find that the research on the stock market is quite diversified, including forecasting the volatility of stock prices, stock price trends, and stock price returns, and trying to obtain more effective forecasts. Experts have struggled to develop effective forecasting methods based on empirical evidence; regardless of the statistical model, DL and the combined time series with DL provide considerable empirical literature support. Previous studies have some limitations: (1) traditional time series models are based on data stationarity and statistical assumptions; (2) a simple time series model Systems 2022, 10, 243 3 of 31 cannot consider multiple variables and be limited by linear relationships; (3) selecting important technical indicators using statistical test methods, which are limited by relevant assumptions and which could not guarantee the degree of correlation to stock prices; and (4) previous studies applied moving windows to forecast future data, and their results showed that the time series model would be unstable and have large errors for data forecast.
To improve the problems mentioned above, this study proposes a time series deep learning model based on integrated multiple variable selection methods for forecasting short-period stock prices. The contributions of this study are as follows: (1) Screen technical indicators as research variables from the literature review, and then transfer the four basic information (opening, highest, lowest, and closing price) of stock trading into the technical indicators; (2) Find the key variables using an integrated indicator selection method (IISM) to synthesize the chosen variable of support vector machines (linear and radial basis function), gene expression programming, multilayer perceptron regression, and generalized regression neural network; (3) Apply LSTM and GRU to build time series models for forecasting stock prices and compare with the listing methods, and we use one-step ahead forecasting to accurately reflect the trading situations of investors in the stock market; (4) Propose two trading policies to compare their profits with the listing methods, and the results can provide investors with a reference to the direction of future investment strategies.
The remaining sections of the current study are arranged as follows. Section 2 describes the relevant literature, including technical indicators, variable selection, and time series deep learning algorithms. Section 3 presents the proposed computational steps and trading policy. The experimental results and discussions are presented in Section 4. The final section presents the conclusions and future work.

Related Work
This section introduces the relevant literature used in the current study, including technical indicators, variable selection, and time series deep learning algorithms.

Technical Indicators
In the stock market, the ultimate goal is to obtain the best investment portfolio to achieve profitability and avoid risks. A good investment portfolio must have marketrelated knowledge, and technical analysis is a good portfolio tool. The earliest technical analysis can be traced back to Cowles [15], who used past prices, transaction volumes, and other available data to predict future price trends. Neely et al. [16] proposed a well-known technical analysis, and they used technical indicators to predict stock risk premiums. Peng et al. [17] summarized 51 technical indicators used in recent financial forecast studies. Wang et al. [18] used five trading rules to generate a total of 105 technical indicators, and their results showed that technical indicators perform better than economic indicators for portfolio allocation. Tsai et al. [19] stated that technical analysis should consider indicators that are representative of past financial market data. Furthermore, Leung and Chong [20] found that the Bollinger band (BB) is better than the moving average because it considers price volatility. These existing studies analyzed the profitability of trading strategies based on various technical indicators [16], and technical indicators are usually composed of two parts: lagging indicators and leading indicators. The lagging indicators are usually used to measure trends, and the leading indicators are usually used to buy or sell signals.
Many technical indicators have been applied in the financial market. Tay and Cao [1] collected five real futures contracts from the Chicago mercantile market as their datasets. The input variables were four lagged relative differences in percentage (RDP(5), RDP(10), RDP (15), and RDP (20)) and a 15-day lagged exponential moving average (EMA(15)) of the closing price. The results showed that the support vector machine outperformed the back proposition neural network. Chang et al. [21] used a piecewise linear and neural network to analyze the nonlinear relationship between closing prices and technical indicators and to reveal the trading signals of historical data. Their technical indicators included four different moving average lags (MA(5), MA(6), MA (10), MA (20)), two different bias lags (BIAS5, BISA10), two different RSIs lag (RSI(6), RSI(12)), a nine-day stochastic line (K%D), Williams %R line, and trading volume. Ahmar [22] developed Sutte technical indicators and compared them with simple moving average and moving average convergence/divergence, and the results showed that Sutte indicators could be used as indicators to forecast stock prices. Lai et al. [23] empirically analyzed the influence of psychological biases on technical signals. The results showed that disposition, information cascade, and anchoring effects significantly impact trading signals.
In the existing literature, either many technical indicators are used, or the technical indicators are derived according to the researcher's preference to predict the price. Therefore, we collect the technical indicators that have appeared in recent high-quality journals and financial market trading, and we summarize those technical indicators repeatedly appearing in our collected literature as the technical indicators of this study. There is a total of 23 technical indicators, as shown in Table 1 and Table A2 in Appendix A.

Indicator Selection
Technical analysis can provide signals for investors to enter and exit the market; hence, it is very important for investors to select the correct technical indicators as the input variables of the model in order to effectively obtain investment signals and avoid investment risks. If too many technical indicators are used to solve the high-dimensional problem, it creates computational complexity and a high cost for a model algorithm [24]. Therefore, selecting important indicators (variable reduction) can help researchers understand data, reduce computational requirements, decrease the impact of high dimensionality, and improve forecast performance [25].
The indicator selection method can be viewed as a search technique for finding new subsets of indicators, combined with evaluation metrics for different subsets of indicators. The simplest method is to test every possible subset of indicators and find the subset of indicators that minimizes the prediction error rate. The indicator selection method can be divided into the wrapper, filter, and embedded methods [26] as follows.
(1) The wrapper method uses the predictive model to evaluate a subset of indicators, and each new subset is used to train a model. Because wrapper methods train a new model for each subset, they are very computationally expensive but usually provide the best performing set of indicators for that particular type of model or typical problem. In traditional regression analysis, the most popular form of indicator selection is stepwise regression, which is a wrapper technique. (2) The filter method uses a proxy instead of error rates to evaluate a subset of indicators.
This method was chosen for fast computation while still capturing the usefulness of the indicator set. Commonly used methods include mutual information, Pearson correlation coefficient, etc. Filters are generally less computationally intensive than wrappers, and many filter methods provide an indicator ranking. One other popular approach is the recursive feature elimination algorithm [27] commonly used with support vector machines to repeatedly build a model and remove indicators with low weights. (3) Embedded methods are an all-encompassing set of techniques that perform indicator selection during model building. These methods tend to fall between filters and wrappers in terms of computational complexity.
Based on the collected literature on technical indicators, we found out that 23 technical indicators repeatedly appear in our collected literature, and the 23 technical indicators are used in this study, as shown in Table 1. To find the key technical indicators, we applied multilayer perceptron regression (MLPR), support vector regression (SVR), generalized regression neural network (GRNN), and gene expression programming (GEP) algorithms to select the technical indicators of each stock market, as these four intelligent algorithms belong to the filter method with less computational complexity and provide an indicator ranking function. The following introduces the four intelligent indicator selection algorithms used in this study.
(1) Multilayer perceptron regression Multilayer perceptron (MLP) is a kind of feedforward neural network that contains at least three layers (input, hidden, and output layer) and uses back proposition to achieve supervised learning [28]. The number of neurons and neural network layers are hyperparameters of the network. Generally, each neuron in the hidden layer has input, weight, and error. Each neuron also has a nonlinear activation function that produces the cumulative output of previous neurons [29]. MLP neurons can freely perform classification or regression based on their activation functions, and MLP uses a high-performance method in random schemes, fitness approximation, and regression analysis [30].
(2) Support vector regression The support vector machine (SVM) was first developed by [31], and has been successfully applied in classification and regression tasks, especially in time series forecasting and financial applications [32]. SVM uses kernel functions to transfer from low-dimensional to highdimensional space, and it has many kernel functions, such as linear and radial basis function (RBF). SVM is well-known in classification problems, and SVM used in regression is called support vector regression (SVR). Previous studies applied SVR to forecast time series patterns and compared linear and RBF kernel functions [33,34]. The results showed that SVR with RBF kernel function is superior to other kernel functions in non-trend forecasting, and SVR with linear kernel function is better than RBF kernel function in trend forecasting.
(3) Generalized regression neural network GRNN provides an estimated value of continuous attributes and converges to the linear or nonlinear regression surface; it has a single-layer learning algorithm with a highdimensional parallel structure [35]. GRNN uses a radial function as its core and has good nonlinear computing performance. There are no model parameters to be trained and the convergence speed is fast. The internal structure of this algorithm includes the input, model, summing, and output layers.

(4) Gene expression programming
The GEP algorithm [36] starts with the random generation of chromosomes of an initial population, and it expresses the chromosomes and evaluates the adaptability of each individual. According to their adaptability to select individuals, the process simulates reproduction, crossover, and mutation; hence, the offspring have new traits and a new generation of individuals. A certain number of generations or stopping rules are set to repeat the above process until a solution is found [36]. GEP is an evolutionary algorithm closely related to genetic algorithms and genetic programming, and it inherits a fixedlength linear chromosome from a genetic algorithm. The advantage of GEP is that all decisions related to the growth of the tree are calculated using the algorithm itself without any manual entry.

Time Series Deep Learning Algorithm
A time series is a kind of continuous data formed in order of time, and its data contain three characteristics: stationarity, seasonality, and trend. A time series data point is a fixed period (for example, one day, hour, minute, etc.), and the difference between time series and regular data is that there is a correlation between time points. Therefore, two adjacent data cannot be considered independent, and the next data can be forecasted using the previous data. Time series forecasting is a challenging task because the basic data generation process is dynamic, nonlinear, and uncertain [37]. Traditional time series models [38] have many forms, representing different random processes; the three most common types are autoregressive (AR), integral (I), and moving average (MA) models, or ARIMA. The ARIMA model and its derivative models have become very popular, mainly due to their flexibility and simplicity in the modeling process [39]. Time series forecasting has many applications, including in finance, meteorology, business, computer science, and interdisciplinary fields.
Recently, powerful computer calculations have made machine learning and deep learning a hot topic. Machine learning learns a model from data (data-driven model). Deep learning is essentially a subset of machine learning that extends the capabilities of machine learning to multilayer neural networks. The financial market usually uses time series data; hence, we used two deep learning algorithms to handle time series as forecast models. This section introduces the two time series deep learning models (LSTM and GRU) used in this study.

Long Short-Term Memory
The recurrent neural network (RNN) was originally a neural network for learning time series data, but the disappearance of the gradients of RNN as the network layer deepens has not been solved. LSTM was proposed by Hochreiter and Schmidhuber [40] to solve the RNN problem. LSTM network is very suitable for processing classification and forecasts based on time series data. LSTM consists of four units [41]: (1) input gate: when data is input, the input gate can control whether to input the value and calculate the value; (2) memory cell: memorizes the calculated value to facilitate the use of the next cell; (3) output gate: controls whether to output the calculated value; if there is no output at this time, the value will be 0; (4) forget gate: controls whether to clear the memory. The sigmoid function is the main rule of LSTM in the equations. According to different inputs and outputs, LSTM has different basic types: (1) many to one: multiple time points to forecast the next time point (such as input: stock price for one week, output: stock price for next Monday); and (2) many to many: multiple related data to forecast the next temporal or next to related data.

Gated Recurrent Unit
GRU is a kind of RNN proposed by Cho et al. [42] and it can speed up execution and reduce memory consumption to improve the shortcomings of LSTM [43]. GRU can achieve the same performance as LSTM, and it is easier to train and greatly improve training efficiency; hence, we are more inclined to use GRU in many cases. GRU is smart because it uses an updated memory gate to simultaneously forget and select memories, while LSTM uses multiple gates (input and forget gates). The advantage of GRU is that the structure of GRU (input and output) is similar to RNN, and the internal idea is similar to LSTM. Compared with LSTM, GRU has fewer parameters, a simpler structure, faster convergence speed, and a better prediction effect [44].

Proposed Method
A stock price trend is considered nonlinear, uncertain, and unstable, and even financial experts cannot accurately forecast prices. Investors believe that stock investment must have a good profit to boost investors' confidence. However, complete historical data and related literature still cannot accurately forecast stock prices. Technical analysis is a good portfolio tool that uses past prices, transaction volumes, and other available data to predict future price trends. Technical indicators from past stock data are related to the forecast stock price trend, and the rise and fall of the trend signal investors entering and exiting the stock market. Technical indicators are usually composed of lagging and leading indicators: the lagging indicators are usually used to measure trends, and the leading indicators are usually applied to buy or sell signals. Furthermore, technical indicators perform better than economic indicators for portfolio allocation [18]. Therefore, this study converts historical data (opening, highest, lowest, and closing prices) of the stock market into technical indicators as research variables.
Stock analysts and investors can use many technical indicators and market indicators as the basis for investment strategies, but not all technical indicators are suitable as input variables for forecast models. In the past, technical analysts used subjective judgments to determine which technical indicators were suitable for the timely reflection of data at a given time and whether the model was effective, but subjective judgments do not provide any factual evidence. Tan [45] stated that the selection of stock data and technical indicators to be used would depend on the following factors: correlation between technical indicators and the stock price, availability (the data must be easily obtainable), the sufficiency of the historical databases (there must be enough sample data), periodicity of the data, and reliability of the data. Therefore, we collected six stock markets as datasets: Taiwan weighted index (TAIEX), Nikkei average index (Nikkei 225), Hang Seng index (HSI), Standard & Poor's index (S&P 500), SSE (China A Shares), and Dow Jones industrial average (DJI). To objectively select important technical indicators, this study applies SVM, GEP, MLPR, and GRNN to screen the important indicators, and then we use the proposed IISM to synthesize the chosen indicators of SVM, GEP, MLPR, and GRNN. The reason for choosing these four models is listed as follows: (1) MLPR can perform regression based on their activation functions and it uses a high-performance method in random schemes, fitness approximation, and regression analysis [30]. (2) SVR is well-known in regression forecast. Previous studies applied SVR to forecast time series patterns [33,34] and their results were better performance in nonlinear forecasting. (3) GRNN uses a radial function as its core and has good nonlinear computing performance [35]; there are no model parameters to be trained and the convergence speed is fast. (4) GEP is an evolutionary algorithm and can be used in forecast problems; the advantage of GEP is that all decisions related to the growth of the tree are calculated using the algorithm itself without any manual entry [36].
Although there are many time series models to forecast stock prices, there is still room for improvement. Current models have (1) assumptions for data stationarity and statistical distribution, (2) no consideration for multiple variables and handling nonlinear relationships, and (3) no strategy for comprehensively selecting important indicators. To address these problems, this study proposes a time series deep learning model based on the IISM method for forecasting stock prices and presents a trading policy to evaluate the profits of different stock markets. In comprehensively selecting important technical indicators, the current study considers that different combinations of lagging and leading indicators will impact the forecast results. We selected the most commonly used technical indicators in the past literature as research variables. Furthermore, we used support vector machines (linear and radial basis functions), gene expression programming, multilayer perceptron regression, and generalized regression neural networks to select important variables and find the key variables by IISM. In building a forecast model, we applied deep learning LSTM and GRU to build a time series model for forecasting stock prices and compare them with three intelligent time series forecast models. In other words, the proposed model is LSTM/GRU combined with the selected key indicators. Therefore, we list the research hypothesis to describe what this research expects to experiment and demonstrate as follows.
Hypothesis 1: The proposed model based on the selected key indicators is a good forecast model for stock markets.

Hypothesis 2:
The proposed model with the selected key indicators has the best total profits.

Hypothesis 3:
The proposed trading policy has better total profits in the stock markets.

Proposed Computational Steps
To easily understand the proposed method, this section explains the five computational steps and a visualization procedure used in this study, as shown in Figure 1. The detailed calculation steps are described below. Step 1: Data collection and preprocessing This study uses the pandas-DataReader of Python programming language [46] to collect six stock markets' data from Yahoo Finance  Table A1. In the data preprocessing, the collected time series data of six stock markets are from 2011 to 2019, and we used each year's data as the dataset unit (six stock markets × nine-year datasets = 54 datasets). The  Table A1. In the data preprocessing, the collected time series data of six stock markets are from 2011 to 2019, and we used each year's data as the dataset unit (six stock markets × nine-year datasets = 54 datasets). The dataset of each year was partitioned into the training data (from January to October) and the testing data (from November to December).
Next, the four basic data (opening, highest, lowest, and closing price) of the stock market were converted into technical indicators; however, different technical indicators had different lag periods, such as EMA (26) Table A2.
Step 2: Indicator selection To reduce the computational complexity and the high cost of the forecast model, this step introduces how to objectively select important technical indicators to solve high-dimensional problems. This study applies SVM (the kernel function is linear and RBF), GEP, MLPR, and GRNN to select important technical indicators for each year's dataset of the six stock markets (a total of 54 datasets). These algorithms ranked the impact of 23 technical indicators on the closing price. The most important indicator took 100 as the highest score, and the other indicators were between 0 and 99 points, depending on their importance. We set a score of less than 1 as the threshold for discarding indicators because their impact is relatively small. Then, we summarized the selected indicators of five algorithms for each year's dataset of the six stock markets (54 datasets). In Table 1, we present only the important indicators selected by the five algorithms in the 2019 DJI stock market as an example.
To find the key variables, the current study proposed a simple integrated indicator selection method (IISM) to synthesize the chosen indicators of SVM, GEP, MLPR, and GRNN. The IISM's purpose is to join the selected indicators of the five algorithms, which is the concept of the union in set theory, to integrate the indicators selected by the five algorithms. Similarly, we used the DJI stock market in 2019 as an example to illustrate that IISM integrated the results of the indicators selected by the five algorithms, as shown in the last column of Table 1. Step 3: Model building Most stock markets usually use time series data; hence, the current step chooses two deep learning algorithms that can handle time series as a forecast model. After selecting key indicators using the IISM method of Step 2, the current step uses the selected key indicators to build a time series deep learning forecast model using LSTM and GRU algorithms (the proposed model). Furthermore, we also used LSTM and GRU algorithms based on the full indicators (23 indicators) to build a time series deep learning forecast model for comparison with the proposed model. Based on the minimum root mean square error (RMSE), in this step, we used the training data to adjust and optimize the parameters of the forecast model, and the time series forecast model was established when the optimized parameters were obtained.
Step 4: Forecast In each dataset of different markets for forecast, the first 10-month period is used for initial training, and those from November to December are selected for testing. Time series forecasting describes forecasting observations at the next time step; hence, it is called one-step ahead forecasting because only a one-time step is forecasted. After the time series forecast model is established (initial training), the current step uses one-step ahead forecasting to forecast the testing data of six stock markets (a total of 54 testing data are implemented) because one-step ahead forecasts can accurately reflect the trading situations of investors in the stock market. In the forecasting process, we forecast only one observation of the testing data each time. That is: (1) when forecasting the first observation, we directly use the established model to forecast the closing price; (2) when forecasting the second observation, the first observation of the testing data will be added to the training data, and we check whether the established model has been corrected before forecasting the second one; (3) when forecasting the third observation, the first and second observations of the testing data will be added to the training data, and we check whether the established model has been corrected before making a forecast; and (4) we repeat this forecasting steps until the last observation of the testing data.
Step 5: Forecast evaluation This study uses the two most common metrics in the literature, RMSE [17] and the mean absolute percentage error (MAPE) [39], to measure forecasting performance and compare the proposed model with the listed models. Furthermore, we use standard deviation (SD) to evaluate forecast stability. The equations of RMSE and MAPE metrics are defined as follows: where y i denotes the actual closing price at time i,ŷ i . represents the closing price forecasted at time i, and n means the number of the testing data.
To strengthen the verification of the proposed model comparison, we compared the proposed model with the other three models (SVR, GRNN, and MLPR) based on the two metrics.

Proposed Trading Policy
Profit maximization can be based on estimates of potential profits and risks. However, designing a profit policy in a complex and volatile stock market is challeng-ing. Every investor wants a winning policy. There is no doubt that in such a complex and volatile stock market, it is not easy to design a profitable strategy. In powerful computation, it is important to use deep learning algorithms to forecast stock prices accurately. However, an accurate stock price forecast is not enough because profitabil-ity is more important for investors. To maximize profits, a good trading policy can bring investment profit, and the greatest profit is the most important thing for decision makers. Therefore, this study proposes two trading policies to compute a profitable unit; further, we also consider the stamp duty of different stock markets in this work. The stamp duty of different countries can refer to [48] (HK, China, and Taiwan are 0.1%; Japan is no financial transaction tax; US is 1.5%). Trading policy 1 is as follows: (1) when the forecast rises >0, buy at the opening price of the next day; and (2) when the forecast falls <0, sell at the opening price of the next day. The first trading policy can be expressed as Equations (3) and (4), and the proposed algorithm for trading pol-icy 1 is shown in Algorithm 1.
Buy signal: If forecast (t + 1)−actual(t) > 0, then buy the opening price of the next day If forecast (t + 1)−actual(t) < 0, then sell the opening price of the next day (4) Trading policy 2 is: (1) buy the opening price of the next day when the forecast rises 1%; (2) sell the opening price of the next day when the forecast falls 1%. The second trading rule can be expressed as Equations (5) and (6).
Buy signal: > 0.01, then buy the opening price of the next day (5) Sel signal: The main differences between the proposed trading policy 1 and the trading policy of Chen et al. [49] are that the proposed trading policy 1: (1) changes its sell signal to a buy signal, and changes its buy signal to a sell signal and (2) changes its closing price to the opening price at the trading time point. To verify, we will compare the profitability of the two proposed trading policies with the trading policy of Chen et al. [49] in Section 4.3.

Experiments and Results
This section introduces the experimental environment, experiment and comparison, profit comparison, and discussion.

Experimental Environment
The experimental environment of this study was a computer with a GTX1650 display card, RAM 16G, and Python 3.7 installed on a Win10 system, and PyCharm was used for programming and compilation. The five forecast algorithms used in this experiment are LSTM, GRU, SVR, GRNN, and MLPR. The current experiment used Python to develop these five forecast models, and we imported LSTM, GRU, and MLPR models using the Keras suite, GRNN model with neupy, and SVR model with sklearn. Among them, adaptive moment estimation (Adam) was selected for optimizing the hyperparameters of LSTM, GRU, and MLPR, and linear and RBF kernel functions were selected for SVR. The parameter settings of the five forecast models are shown in Table 2.

Experiment and Comparison
This section describes the proposed computational steps for implementing the experiments, and we introduce these experimental results according to the key indicators, descriptive statistics, and forecast comparison as follows.

(A) Key indicators
In selecting key indicators, the current study applies SVM (kernel function is linear and RBF), GEP, MLPR, and GRNN to select important technical indicators for each year dataset of the six stock markets, and then we use IISM in computational step 2 of Section 3.1 to find the key technical indicators from all 54 datasets (six stock markets × nine-year datasets = 45 datasets), as shown in Table 3. We found that the indicators that were not selected were RSI, PSY(12), %K, and Volume; the ones that were selected once were PSY(24), W%R, and PROC; and the ones that were selected twice were %D. Further, we observed that the indicator LAG had the highest frequency of 45 times, which is the most key indicator in all 45 datasets of this study. Secondly, EMA(26) was selected 44 times, and EMA(12) was selected 43 times. The remaining indicators are shown in Table 3

(C) Forecast comparison
After selecting the key indicators, the current study used all 23 indicators (full) of each dataset to forecast closing prices using the proposed model and compared them with the SVR, GRNN, and MLPR models. Based on RMSE and MAPE metrics, the forecast results of full indicators are shown in Tables 5 and 6. We observed that the GRU model was stable with a smaller standard deviation and superior to the other four models in most of the datasets for the six stock markets. The LSTM model was the second-best model, and it performed better than the SVR, GRNN, and MLPR models.   As previously mentioned, the LSTM and GRU models had better performances. Hence, we compared the selected key indicators of each dataset with full indicators of the LSTM and GRU models, and the results are shown in Tables 7 and 8. From the RMSE and MAPE metrics, the GRU combined with the selected key indicators was a better forecast model in the DJI, NIKKE225, and TAIEX stock markets. In the HSI and S&P 500 stock markets, the LSTM combined with the selected key indicators was better than the other forecast models in terms of RMSE, and it had a relatively low MAPE in the HSI stock market. In summary, the proposed model (GRU/LSTM combined with the selected key indicators) is a good forecast model for stock markets.    From Table 4 of the descriptive statistics, the DJI, HSI, and Nikkei 225 stock markets had large volatility in 2017. Therefore, we plotted the forecast and actual closing prices of the testing data for LSTM and GRU models combined with full and selected key indicators, which are shown in Figures 2-4. The results showed that the proposed combined LSTM and GRU models with the selected key indicators were the best forecast model in a large fluctuation of stock markets.

Profit Comparison
This section describes the application of the two proposed trading policies to the calculation of profits. We also compared these policies with the trading rules proposed by Chen et al. [49]. The comparitive profits of proposed policy 1 and Chen

Profit Comparison
This section describes the application of the two proposed trading policies to the calculation of profits. We also compared these policies with the trading rules proposed by Chen et al. [49].

Profit Comparison
This section describes the application of the two proposed trading policies to the calculation of profits. We also compared these policies with the trading rules proposed by Chen et al. [49]. The comparitive profits of proposed policy 1 and Chen et al.'s [49] trading policy are shown in Table 9, and the comparitive profits between proposed policy 2 and Chen et al.'s [49] trading policy are shown in Table 10.
Tables 9 and 10 show that the total profits of the two proposed trading policies were better than Chen et al.'s [49] in the six stock markets. To compare the total profits of trading policies 1 and 2, we summarized Tables 9 and 10 into Table 11. The proposed model (combined GRU with the selected key indicators) had the best total profits, except for HSI and SSE (China A Shares), as shown in trading policy 1 of Table 11. In trading policy 2, the proposed combined model won the total profits in the TAIEX stock market. Figure 5 shows the total profits of trading policies 1 and 2 for the six stock markets, and it shows that the best policy was the proposed trading policy 1 in DJI, S&P 500, HSI, SSE (China A Shares), and Nikkei 225; investing in TAIEX, the proposed trading policy 2 was the best policy. In summary, we suggest using the proposed trading policy 1 in DJI, S&P 500, HSI, SSE (China A Shares), and Nikkei 225, but we recommend investing in TAIEX using the proposed trading policy 2 because investments in TAIEX must wait for a strong trading signal (forecasted rise and fall >1%). Note: the bold number denotes the best profits/total profits in the eight different combined methods. Note: the bold number denotes the best profits/total profits in the eight different combined methods.

Discussion and Practical Applicability
In what follows, we discuss some major observations from the experiments and the results of the study.
(1) Selecting key indicators Selecting important indicators can effectively reduce computational requirements and improve forecast performance [25]. This study used SVM (the kernel function is linear and RBF), GEP, MLPR, and GRNN to select important indicators, and then we used the proposed IISM to find the key indicators for all 54 datasets. From Table 3, we found that the indicators PSY_12, PSY_24, RSI, %K, %D, W%R, PROC, and Volume were selected between 0 and 2 times and that these indicators had little influence on forecasting stock prices. Thus, we could carefully remove these indicators in future research. Lastly, we selected 15 key indicators and ranked them as LAG > EMA (26)

Discussion and Practical Applicability
In what follows, we discuss some major observations from the experiments and the results of the study.
(1) Selecting key indicators Selecting important indicators can effectively reduce computational requirements and improve forecast performance [25]. This study used SVM (the kernel function is linear and RBF), GEP, MLPR, and GRNN to select important indicators, and then we used the proposed IISM to find the key indicators for all 54 datasets. From Table 3, we found that the indicators PSY_12, PSY_24, RSI, %K, %D, W%R, PROC, and Volume were selected between 0 and 2 times and that these indicators had little influence on forecasting stock prices. Thus, we could carefully remove these indicators in future research. Lastly, we selected 15 key indicators and ranked them as LAG > EMA (26)  Further, this study used the selected key indicators to test the lag period using the autoregressive distributed lag model, and the lag period and the key indicators were input into the proposed model. This did not yield better results because the technical indicators were effective in obtaining information about the gap period without excessively adding the lagged indicators. Thus, we suggest that traders and investors prioritize the above eight key indicators and add their own practical experiences in analyzing stock price trends. Further, the influence of investor psychological factors must be considered when investing in China's A-shares.
(2) Fluctuation and forecast ability The volatility indicator was introduced 30 years ago, and many studies on forecasting the actual volatility of the stock market and the exchange rate have demonstrated its superior ability [51]. Fluctuation can be measured in a number of ways, including technical indicators (such as Cboe volatility index, BB, and average true range) and descriptive statistics (such as standard deviation and range). The current study used simple standard deviations and ranges that were both large to simultaneously determine whether the stock market has large volatility because technical indicators were used to measure the short-term volatility. From the descriptive statistics in Table 4 for 2017, the DJI, HSI, and Nikkei 225 stock markets had large volatility because 2017 was the year the market finally saw the end of a ten-year financial crisis [52], and the stock market hit a record high that encouraged investor psychology again, allowing a full frenzy. Further, HSI stock fluctuated drastically from 2015 to 2019 because China's stock market bubble occurred in 2015-2016 [53], and many of China's investors moved to the nearby Hong Kong stock market.
In forecasting, we observed that the proposed combined LSTM/GRU with the selected key indicators reduced the RMSE and MAPE, and it was the best forecast model for the large fluctuation market of 2017, as shown in Tables 7 and 8 and Figures 2-4. In a relatively stable market, the GRU combined with the selected key indicators was a better forecast model for the DJI, NIKKE225, and TAIEX stock markets, and the LSTM combined with the selected key indicators was better than the other forecast models in terms of RMSE in the HSI and S&P 500 stock markets. In summary, the results showed that the proposed model was not affected by fluctuation and non-fluctuation markets and showed good forecast ability.
(3) LSTM and GRU advantages Due to the rapid development of computer science, deep learning can handle many parameter problems and has higher speed, higher accuracy, and better robustness in complex situations. One of the main advantages of deep learning is that its feature layers are not designed by humans [54]. Conversely, features are learned from data using a universal learning procedure. The advantage of LSTM is that it can capture time information in time series data, and it can solve the disappearance of the gradients of RNN as the network layer deepens [40]. Furthermore, LSTM is very suitable for forecasting stock prices, and LSTM has an advantage compared to memory-free methods [9]. GRU is a kind of RNN proposed by Cho et al. [42] and it can accelerate execution and reduce memory consumption to improve the shortcomings of LSTM [43]. GRU does not lose to the performance of LSTM, and it is easier to train and greatly improves implementation efficiency. From Tables 5-8, the GRU combined with the selected key indicators is a better forecast model than the listing models for the DJI, NIKKE225, and TAIEX stock markets; hence, we are more inclined to use GRU in forecasting stock prices.

(4) Trading policy
In previous studies, all stocks were traded at the closing price during the period [55]. However, this work proposes trading policy 1, in which the stocks are traded at the opening price to compute the profitable unit, and changes the concept of "buy on lows and sell on highs" to "sell on lows and buy on highs." To verify the proposed trading policy 1, we conducted a comparative experiment, and the results showed that the total profits of the proposed trading policy 1 were better than those of Chen et al. [49] in the six stock markets.
Further, this study proposes trading policy 2 to verify whether we need to wait until the forecasted value rises and falls >1% and the profit is relatively high. The results showed that the proposed trading policy 2, only investing in TAIEX, had higher profits among the six stock markets. Based on the experimental results in Section 4.3, we recommend that: (1) the trading time should change the closing price to the opening price at the trading time point, (2) changing the concept of "buy on lows and sell on highs," and (3) determining whether to wait until the forecasted value rises and falls >1%, based on the characteristics of different markets. Hypothesis 1: The proposed model based on the selected key indicators is a good forecast model for stock markets. Accepted, as shown in Tables 7 and 8.

Hypothesis 2:
The proposed model with the selected key indicators has better total profits. Accepted, as shown in Table 11.

Hypothesis 3:
The proposed trading policy 1 has better total profits in the stock markets. Accepted, as shown in Table 11.
(6) Practical applicability From the market profits perspective and each year's investment in six markets, we find the benchmarks as follows. (i) In terms of profits of six markets, we see that the Dow Jones stock market has the most profits, as shown in Table 11, and then we set the Dow Jones stock market as the benchmark. (ii) From profits of each year for six markets (as Table 9 Based on the results of this study, we provide four suggestions for investors as references. (i) Consider the eight technical indicators (LAG, EMA, MA, BIAS, MO, BB, DIF, and MCAD) and add their own practical experience in analyzing stock price trends. (ii) Apply GRU combined with the selected key indicators to forecast stock prices because the proposed model can accelerate execution and reduce memory consumption. (iii) Use one step ahead to forecast stock prices because it can accurately reflect the trading situations of investors in the stock market. (iv) Employ the proposed trading policy 1 in the six stock markets and could consider the proposed trading policy 2 in the TAIEX stock market.

(7) Opportunity costs
Opportunity cost is the potential benefit that an investor misses out on when choosing an alternative [56]. Understanding the opportunities that investors may miss when choosing one investment over another allows them to make better decisions. From the benchmarks of discussion, the Dow Jones stock market is a benchmark, and we calculate some simple opportunity costs based on DJI and 2018 as benchmarks, as shown in Table 12. The results show that investing in the S&P 500 instead of DJI will lose an opportunity cost of 17,669 units based on total profits of six markets; if we invest in S&P 500 but not in DJI, we will lose an opportunity cost of 3782.79 units from the total profits of six markets in 2018.

Conclusions
Investment has profits and risks; finding how to avoid risks and make profits is the ultimate goal of investors. Many investors have applied the relevant information systems to collect data and investment experience for ultimate gainful goals, which can bring profitable confidence. In the global investment market, stock investment is affected by many external environmental factors, and the stock market has many uncertain factors. It is difficult to correctly identify the influencing factors. Moreover, relevant factors and the stock price are nonlinear and nonstationary; hence, it is not easy to accurately forecast the stock price.
Although previous studies have proposed many forecast stock price models based on statistics and machine learning, their forecast abilities are still sub-optimal. Thus, investors need a forecasting model that has accurate time series forecast capabilities and considers the influence of different factors. Therefore, this study proposed a deep learning LSTM/GRU combined with the selected key indicators, which used a one-step ahead forecast to accurately reflect the trading situations of investors in the stock market. The experimental results show that the proposed model is not affected by fluctuation and non-fluctuation markets and shows good forecast ability. This study also proposed two trading policies to verify the validation of profits. The results show that the total profit of our proposed trading policy 1 is better than that of Chen et al. [49] in six stock markets. Based on the results of this study, we list the innovative aspects as follows.
(1) This study collects technical indicators that have appeared in recent high-quality journals and financial market transactions, and then we summarize the technical indicators that frequently recur in the collected literature as the technical indicators of this study. Although we use the one-step ahead forecast to accurately reflect the trading situation of investors in the stock market, the limitations of this study are that the stock price forecast is a short-term forecast, and our collected stock data is daily data instead of minute-byminute data. Future studies may collect more indicators (fundamental, economic, and commodity) from the market and literature to build a time series forecast model and combine the intelligent method with a deep learning algorithm to develop a forecast system of stock prices. Table A1. Six stock markets [Source: Authors' own processing].

HSI
The HSI is an important indicator that reflects the Hong Kong stock market, and the index is calculated from the market value of fifty constituent stocks of the Hang Seng Index.
TAIEX TAIEX is a weighted index of Taiwan, which is regarded as an indicator of the trend of Taiwan's economy.

Nikkei 225
Nikkei 225 is a stock price index of 225 varieties of the Tokyo Stock Exchange.

S&P 500
The US Standard & Poor 500 is the average record of the US stock market since 1957, covering 500 listed companies in the US.

DJI
The Dow Jones industrial average includes the 30 largest and most well-known listed companies in the United States.

SSE
The Shanghai Stock Exchange (SSE) is one of the two Chinese A shares.

MA(5) MA(20)
Moving average is used to underline the direction of a trend and smooth out price and volume fluctuations, and it is defined in the following: price(t−i) n , where n = 5, and 20.
Kannan et al. [57] BB up BB down A Bollinger band defined by a set of trend lines plotted two standard deviations (positively and negatively) away from a simple moving average (MA) of a security's price.
Leung and Chong [20] RDP(1) The actual closing price is transformed into a relative difference in the percentage of the price, and it is defined in the following formula: RDP(1) = price(t)−price(t−1) price(t−1) × 100.

Tay and Cao [1]
BIAS(6) BIAS(12) BIAS (24) Bias ratio is the difference between closing price and moving average, and it is defined in the following formula: BI AS(t) = close−MA t MA t , where t = 6, 12, and 24.
Chang et al. [21] RSI The relative strength index shows the most recent stock profit and loss comparison, and the purpose is to determine the overbought and oversold conditions of assets.
Tsai et al. [19] EMA (12) EMA (26) The exponential moving average is calculated by the weighted average from the current price to the past price, and it is defined as follows: where α = 2 i+1 , i = 12, and 26.
Nakano et al. [58] MACD (DEM) DIF OSC Moving average convergence/divergence shows the difference between the fast and slow exponential moving average of the closing price, and MACD is composed of three elements: difference (DIF), Demand index (DEM, signal line also called MACD), Oscillator (OSC). They are defined as follows: DIF = EMA(12) − EMA(26), DEM = EMA(9), and OSC = DIF − DEM.

Indicator Description Reference
PSY (12) PSY (24) The psychological line is a ratio of rising over a period, and it reflects the purchasing power relative to the sales ability. It is defined as follows: PSY(N) = the number of rising days in N days N × 100, where N = 12, and 24.
Lai et al. [23] WMS%R Williams %R is a momentum indicator range from 0 to −100, and it is used to measure overbought and oversold levels. Williams %R can be used to find market entry and exit points, and this indicator is very similar to the stochastic %K and %D. Naik and Mohan [59] Stochastic K% Stochastic D% Stochastic oscillator %K and %D are momentum indicators, which can show the position relative to the high/low range over a period of time.
Chang and Fan [60] PROC Percentage of price change measures the percentage change in price between the current price and the price of a certain number of periods ago.
Anish and Majhi [61] MO (1) Momentum measures the amount of change in security prices in a given time and displays the rate of change in stock prices, and its formula is defined as follows: .
Chen et al. [12] Volume Trading volume is a measure of the completed transactions of specific security within a specific period of time. It measures two very important factors: market activity and liquidity.