Mathematical Problems in Engineering

Volume 2018, Article ID 9280590, 12 pages

https://doi.org/10.1155/2018/9280590

## Predicting Stock Price Trend Using MACD Optimized by Historical Volatility

Department of Mathematics, Korea University, Seoul 02841, Republic of Korea

Correspondence should be addressed to Junseok Kim; rk.ca.aerok@mikdfc

Received 18 September 2018; Revised 13 November 2018; Accepted 21 November 2018; Published 25 December 2018

Academic Editor: Luis Martínez

Copyright © 2018 Jian Wang and Junseok Kim. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

#### Abstract

With the rapid development of the financial market, many professional traders use technical indicators to analyze the stock market. As one of these technical indicators, moving average convergence divergence (MACD) is widely applied by many investors. MACD is a momentum indicator derived from the exponential moving average (EMA) or exponentially weighted moving average (EWMA), which reacts more significantly to recent price changes than the simple moving average (SMA). Traders find the analysis of 12- and 26-day EMA very useful and insightful for determining buy-and-sell points. The purpose of this study is to develop an effective method for predicting the stock price trend. Typically, the traditional EMA is calculated using a fixed weight; however, in this study, we use a changing weight based on the historical volatility. We denote the historical volatility index as HVIX and the new MACD as MACD-HVIX. We test the stability of MACD-HVIX and compare it with that of MACD. Furthermore, the validity of the MACD-HVIX index is tested by using the trend recognition accuracy. We compare the accuracy between a MACD histogram and a MACD-HVIX histogram and find that the accuracy of using MACD-HVIX histogram is 55.55% higher than that of the MACD histogram when we use the buy-and-sell strategy. When we use the buy-and-hold strategy for 5 and 10 days, the prediction accuracy of MACD-HVIX is 33.33% and 12% higher than that of the traditional MACD strategy, respectively. We found that the new indicator is more stable. Therefore, the improved stock price forecasting model can predict the trend of stock prices and help investors augment their return in the stock market.

#### 1. Introduction

Securities investment is a financial activity influenced by many factors such as politics, economy, and psychology of investors. Its process of change is nonlinear and multifractal [1]. The stock market has high-risk characteristics; i.e., if the stock price volatility is excessive or the stability is low, the risk is uncontrollable. Financial asset returns in the short term are persistent; however, those in the long term will be reversed [2].

Asness [3] reported that the stock, foreign exchange, and commodity markets have a trend. Hassan [4] noted that complex calculations are not particularly effective for predicting stock markets. Many trend analysis indicators and prediction methods for financial markets have been proposed. Pai [5] used Internet search trends and historical trading data to predict stock markets using the least squares support vector regression model. Lahmiri [6] accurately predicted the minute-ahead stock price by using singular spectrum analysis and support vector regression. Researchers have also used other methods to forecast stock markets. Singh et al. [7] designed a forecasting model consisting of fuzzy theory and particle swarm optimization to predict stock markets using historical data from the State Bank of India. Lahmiri et al. [8] proposed an intelligent ensemble forecasting system for stock market fluctuations based on symmetric and asymmetric wavelet functions. Das et al. [9] proposed a hybridized machine-learning framework using a self-adaptive multipopulation-based Jaya algorithm for forecasting the currency exchange value. Laboissiere et al. [10] developed a model involving correlation analysis and artificial neural networks (NNs) to predict the stock prices of Brazilian electric companies. Lei [11] proposed a wavelet NN prediction method for the stock price trend based on rough set attribute reduction. Lahmiri [12] used variational mode decomposition to forecast the intraday stock price. Lahmiri [13] addressed the problem of technical analysis information fusion and reported that technical information fusion in an NN ensemble architecture improves the prediction accuracy. In [14], the authors argued that time series of stock prices are nonstationary and highly noisy. This led the authors to propose the use of a wavelet denoising-based backpropagation (WDBP) NN for predicting the monthly closing price of the Shanghai composite index. Shynkevich et al. [15] investigated the impact of varying the input window length and the highest prediction performance was observed when the input window length was approximately equal to the forecast horizon. In [16], a prediction model based on the input/output data plan was developed by means of the adaptive neurofuzzy inference system method representing the fuzzy inference system. Zhou et al. [17] proposed a stock market prediction model based on high-frequency data using generative adversarial nets. Wang et al. [18] used a bimodal algorithm with a data-divider to predict the stock index. In [19], the author used multiresolution analysis techniques to predict the interest rate next-day variation. Using K-line patterns’ predictive power analysis, Tao et al. [20] found that their proposed approach can effectively improve prediction accuracy for stock price direction and reduce forecast error.

We will introduce the concept of moving average convergence divergence (MACD) and help the readers understand its principle and application in Section 2. Although the MACD oscillator is one of the most popular technical indicators, it is a lagging indicator. In Section 3, we propose an improved model called MACD-HVIX to deal with the lag factor. In Section 4, data for empirical research are described. Finally, in Section 5, we develop a trading strategy using MACD-HVIX and employ actual market data to verify its validity and reliability. We also compare the prediction accuracy and cumulative return of the MACD-HVIX histogram with those of the MACD histogram. The performance of MACD-HVIX exceeds that of MACD. Therefore, the trading strategy based on the MACD-HVIX index is useful for trading. Section 6 presents our conclusion.

#### 2. MACD and Its Strategy

MACD evolved from the exponential moving average (EMA), which was proposed by Gerald Appel in the 1970s. It is a common indicator in stock analysis. The standard MACD is the 12-day EMA subtracted by the 26-day EMA, which is also called the DIF. The MACD histogram, which was developed by T. Aspray in 1986, measures the signed distance between the MACD and its signal line calculated using the 9-day EMA of the MACD, which is called the DEA. Similar to the MACD, the MACD histogram is an oscillator that fluctuates above and below the zero line. The construction formula is as follows: where , , and . The weight number is a fixed value equal to . The number of the MACD histogram is usually called the MACD bar or OSC. The analysis process of the cross and deviation strategy of DIF and DEA includes the following three steps.

(i) Calculate the values of DIF and DEA.

(ii) When DIF and DEA are positive, the MACD line cuts the signal line in the uptrend, and the divergence is positive, there is a buy signal confirmation.

(iii) When DIF and DEA are negative, the signal line cuts the MACD line in the downtrend, and the divergence is negative, there is a sell signal confirmation.

#### 3. MACD-HVIX Weighted by Historical Volatility and Its Strategy

The essence of a good technical indicator is a smooth trading strategy; i.e., the constructed index must be a stationary process. We present an empirical study in Section 5. The validity and sensitivity of MACD have a strong relationship with the choice of parameters. Different investors choose different parameters to achieve the best return for different stocks. In this study, the weight is based on the historical volatility. It is expected that the accuracy and stability of MACD can be improved. The construction formula is as follows:Here, the weight changes over time; HVIX is the change index of the historical volatility of a stock. The HVIX in this paper is the change index of the volatility in the past days. It is similar to the market volatility index VIX used by the Chicago options exchange. It reflects the panic of the market to a certain extent; thus, it is also called the panic index. The above process is expressed by the code shown in Algorithm 1.