Research Article Predicting Stock Price Trend Using MACD Optimized by Historical Volatility
Total Page:16
File Type:pdf, Size:1020Kb
Hindawi Mathematical Problems in Engineering Volume 2018, Article ID 9280590, 12 pages https://doi.org/10.1155/2018/9280590 Research Article Predicting Stock Price Trend Using MACD Optimized by Historical Volatility Jian Wang and Junseok Kim Department of Mathematics, Korea University, Seoul , Republic of Korea Correspondence should be addressed to Junseok Kim; [email protected] 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. Tis 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. With the rapid development of the fnancial 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 signifcantly to recent price changes than the simple moving average (SMA). Traders fnd the analysis of 12- and 26-day EMA very useful and insightful for determining buy-and-sell points. Te purpose of this study is to develop an efective method for predicting the stock price trend. Typically, the traditional EMA is calculated using a fxed 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 fnd 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. Terefore, 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 predicted the minute-ahead stock price by using singular spectrum analysis and support vector regression. Researchers Securities investment is a fnancial activity infuenced by have also used other methods to forecast stock markets. many factors such as politics, economy, and psychology of Singh et al. [7] designed a forecasting model consisting of investors. Its process of change is nonlinear and multifractal fuzzy theory and particle swarm optimization to predict [1]. Te stock market has high-risk characteristics; i.e., if the stock markets using historical data from the State Bank of stock price volatility is excessive or the stability is low, the risk India. Lahmiri et al. [8] proposed an intelligent ensemble is uncontrollable. Financial asset returns in the short term are forecasting system for stock market fuctuations based on persistent; however, those in the long term will be reversed symmetric and asymmetric wavelet functions. Das et al. [9] [2]. proposed a hybridized machine-learning framework using Asness [3] reported that the stock, foreign exchange, a self-adaptive multipopulation-based Jaya algorithm for and commodity markets have a trend. Hassan [4] noted forecasting the currency exchange value. Laboissiere et al. that complex calculations are not particularly efective for [10] developed a model involving correlation analysis and predicting stock markets. Many trend analysis indicators artifcial neural networks (NNs) to predict the stock prices and prediction methods for fnancial markets have been of Brazilian electric companies. Lei [11] proposed a wavelet proposed. Pai [5] used Internet search trends and historical NN prediction method for the stock price trend based on trading data to predict stock markets using the least squares rough set attribute reduction. Lahmiri [12] used variational support vector regression model. Lahmiri [6] accurately mode decomposition to forecast the intraday stock price. 2 Mathematical Problems in Engineering Lahmiri [13] addressed the problem of technical analysis OSCt = DIFt − DEAt, information fusion and reported that technical information (1) fusion in an NN ensemble architecture improves the predic- tion accuracy. In [14], the authors argued that time series where m =12,n =26,andp =9.Teweightnumber of stock prices are nonstationary and highly noisy. Tis led � is a fxed value equal to 2/(m +1).Tenumberofthe the authors to propose the use of a wavelet denoising-based MACD histogram is usually called the MACD bar or OSC. backpropagation (WDBP) NN for predicting the monthly Te analysis process of the cross and deviation strategy of DIF closing price of the Shanghai composite index. Shynkevich et and DEA includes the following three steps. al. [15] investigated the impact of varying the input window (i) Calculate the values of DIF and DEA. length and the highest prediction performance was observed (ii) When DIF and DEA are positive, the MACD line cuts when the input window length was approximately equal to the signal line in the uptrend, and the divergence is positive, the forecast horizon. In [16], a prediction model based on there is a buy signal confrmation. the input/output data plan was developed by means of the (iii) When DIF and DEA are negative, the signal line adaptive neurofuzzy inference system method representing cuts the MACD line in the downtrend, and the divergence thefuzzyinferencesystem.Zhouetal.[17]proposedastock is negative, there is a sell signal confrmation. market prediction model based on high-frequency data using generative adversarial nets. Wang et al. [18] used a bimodal 3. MACD-HVIX Weighted by Historical algorithm with a data-divider to predict the stock index. In [19], the author used multiresolution analysis techniques Volatility and Its Strategy to predict the interest rate next-day variation. Using K-line Te essence of a good technical indicator is a smooth trading patterns’ predictive power analysis, Tao et al. [20] found that strategy; i.e., the constructed index must be a stationary their proposed approach can efectively improve prediction process. We present an empirical study in Section 5. Te accuracy for stock price direction and reduce forecast error. validity and sensitivity of MACD have a strong relationship We will introduce the concept of moving average con- with the choice of parameters. Diferent investors choose vergence divergence (MACD) and help the readers under- diferent parameters to achieve the best return for diferent stand its principle and application in Section 2. Although stocks. In this study, the weight is based on the historical the MACD oscillator is one of the most popular technical volatility. It is expected that the accuracy and stability of indicators, it is a lagging indicator. In Section 3, we propose MACD can be improved. Te construction formula is as an improved model called MACD-HVIX to deal with the lag follows: factor. In Section 4, data for empirical research are described. m Finally, in Section 5, we develop a trading strategy using (EMA − HVIX)t (St) MACD-HVIX and employ actual market data to verify its ∑� � � validity and reliability. We also compare the prediction accu- �=1 �−� m � = � (EMA − HVIX)t−1 + � St racy and cumulative return of the MACD-HVIX histogram ∑�=0 ��−� ∑�=0 ��−� with those of the MACD histogram. Te performance of ( >1) , MACD-HVIX exceeds that of MACD. Terefore, the trading t strategy based on the MACD-HVIX index is useful for m (EMA − HVIX)1 = S1, trading. Section 6 presents our conclusion. (2) (MACD − HVIX)t = (DIF − HVIX)t 2. MACD and Its Strategy m n = (EMA − HVIX)t (St)−(EMA − HVIX)t (St), MACD evolved from the exponential moving average p (DEA − HVIX)t = EMA ((DIF − HVIX)t), (EMA), which was proposed by Gerald Appel in the 1970s. It t is a common indicator in stock analysis. Te standard MACD (OSC − HVIX)t = (DIF − HVIX)t − (DEA − HVIX)t . is the 12-day EMA subtracted by the 26-day EMA, which is also called the DIF. Te MACD histogram, which was Here, the weight changes over time; HVIX is the change index developedbyT.Asprayin1986,measuresthesigneddistance of the historical volatility of a stock. Te HVIX in this paper between the MACD and its signal line calculated using the isthechangeindexofthevolatilityinthepastdays.Itis 9-day EMA of the MACD, which is called the DEA. Similar similar to the market volatility index VIX used by the Chicago to the MACD, the MACD histogram is an oscillator that options exchange. It refects the panic of the market to a fuctuates above and below the zero line. Te construction certain extent; thus, it is also called the panic index. Te above formula is as follows: processisexpressedbythecodeshowninAlgorithm1. Te analysis process of the cross and deviation strategy m ( )=(1−�) m +�× ( >1) , EMAt St EMAt−1 St t of DIF-HVIX and DEA-HVIX includes the following three m steps. EMA1 = S1, m n (i) Calculate the values of DIF-HVIX and DEA-HVIX. MACDt = DIFt = EMAt (St)−EMAt (St), (ii) When DIF-HVIX and DEA-HVIX are positive, the p DEAt = EMAt (DIFt), MACD-HVIX line cuts the signal line of HVIX in the Mathematical Problems in Engineering