13
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. is 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 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. e 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. erefore, 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]. e 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. Hindawi 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 ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Research ArticlePredicting Stock Price Trend Using MACD Optimized byHistorical Volatility

JianWang and Junseok Kim

Department of Mathematics Korea University Seoul 02841 Republic of Korea

Correspondence should be addressed to Junseok Kim cfdkimkoreaackr

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

Academic Editor Luis Martınez

Copyright copy 2018 JianWang and Junseok Kim This is an open access article distributed under the Creative Commons AttributionLicense which permits unrestricted use distribution and reproduction in any medium provided the original work is properlycited

With the rapid development of the financial market many professional traders use technical indicators to analyze the stockmarket As one of these technical indicatorsmoving average convergence divergence (MACD) is widely applied bymany investorsMACD is a momentum indicator derived from the exponential moving average (EMA) or exponentially weighted moving average(EWMA) which reactsmore significantly to recent price changes than the simple moving average (SMA) Traders find the analysisof 12- and 26-day EMA very useful and insightful for determining buy-and-sell points The purpose of this study is to develop aneffective method for predicting the stock price trend Typically the traditional EMA is calculated using a fixed weight howeverin this study we use a changing weight based on the historical volatility We denote the historical volatility index as HVIX andthe new MACD as MACD-HVIX We test the stability of MACD-HVIX and compare it with that of MACD Furthermore thevalidity of the MACD-HVIX index is tested by using the trend recognition accuracyWe compare the accuracy between a MACDhistogram and a MACD-HVIX histogram and find that the accuracy of using MACD-HVIX histogram is 5555 higher than thatof the MACD histogram when we use the buy-and-sell strategy When we use the buy-and-hold strategy for 5 and 10 days theprediction accuracy of MACD-HVIX is 3333 and 12 higher than that of the traditional MACD strategy respectivelyWe foundthat the new indicator is more stable Therefore the improved stock price forecasting model can predict the trend of stock pricesand help investors augment their return in the stock market

1 Introduction

Securities investment is a financial activity influenced bymany factors such as politics economy and psychology ofinvestors Its process of change is nonlinear and multifractal[1] The stock market has high-risk characteristics ie if thestock price volatility is excessive or the stability is low the riskis uncontrollable Financial asset returns in the short term arepersistent however those in the long term will be reversed[2]

Asness [3] reported that the stock foreign exchangeand commodity markets have a trend Hassan [4] notedthat complex calculations are not particularly effective forpredicting stock markets Many trend analysis indicatorsand prediction methods for financial markets have beenproposed Pai [5] used Internet search trends and historicaltrading data to predict stock markets using the least squaressupport vector regression model Lahmiri [6] accurately

predicted the minute-ahead stock price by using singularspectrum analysis and support vector regression Researchershave also used other methods to forecast stock marketsSingh et al [7] designed a forecasting model consisting offuzzy theory and particle swarm optimization to predictstock markets using historical data from the State Bank ofIndia Lahmiri et al [8] proposed an intelligent ensembleforecasting system for stock market fluctuations based onsymmetric and asymmetric wavelet functions Das et al [9]proposed a hybridized machine-learning framework usinga self-adaptive multipopulation-based Jaya algorithm forforecasting the currency exchange value Laboissiere et al[10] developed a model involving correlation analysis andartificial neural networks (NNs) to predict the stock pricesof Brazilian electric companies Lei [11] proposed a waveletNN prediction method for the stock price trend based onrough set attribute reduction Lahmiri [12] used variationalmode decomposition to forecast the intraday stock price

HindawiMathematical Problems in EngineeringVolume 2018 Article ID 9280590 12 pageshttpsdoiorg10115520189280590

2 Mathematical Problems in Engineering

Lahmiri [13] addressed the problem of technical analysisinformation fusion and reported that technical informationfusion in an NN ensemble architecture improves the predic-tion accuracy In [14] the authors argued that time seriesof stock prices are nonstationary and highly noisy This ledthe authors to propose the use of a wavelet denoising-basedbackpropagation (WDBP) NN for predicting the monthlyclosing price of the Shanghai composite index Shynkevich etal [15] investigated the impact of varying the input windowlength and the highest prediction performance was observedwhen the input window length was approximately equal tothe forecast horizon In [16] a prediction model based onthe inputoutput data plan was developed by means of theadaptive neurofuzzy inference system method representingthe fuzzy inference system Zhou et al [17] proposed a stockmarket predictionmodel based on high-frequency data usinggenerative adversarial nets Wang et al [18] used a bimodalalgorithm with a data-divider to predict the stock indexIn [19] the author used multiresolution analysis techniquesto predict the interest rate next-day variation Using K-linepatternsrsquo predictive power analysis Tao et al [20] found thattheir proposed approach can effectively improve predictionaccuracy for stock price direction and reduce forecast error

We will introduce the concept of moving average con-vergence divergence (MACD) and help the readers under-stand its principle and application in Section 2 Althoughthe MACD oscillator is one of the most popular technicalindicators it is a lagging indicator In Section 3 we proposean improved model called MACD-HVIX to deal with the lagfactor In Section 4 data for empirical research are describedFinally in Section 5 we develop a trading strategy usingMACD-HVIX and employ actual market data to verify itsvalidity and reliability We also compare the prediction accu-racy and cumulative return of the MACD-HVIX histogramwith those of the MACD histogram The performance ofMACD-HVIX exceeds that of MACDTherefore the tradingstrategy based on the MACD-HVIX index is useful fortrading 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 Itis a common indicator in stock analysis The standard MACDis the 12-day EMA subtracted by the 26-day EMA whichis also called the DIF The MACD histogram which wasdeveloped by T Aspray in 1986 measures the signed distancebetween the MACD and its signal line calculated using the9-day EMA of the MACD which is called the DEA Similarto the MACD the MACD histogram is an oscillator thatfluctuates above and below the zero line The constructionformula is as follows

EMAmt (St) = (1 minus 120572) EMAm

tminus1 + 120572 times St (t gt 1) EMAm1 = S1

MACDt = DIFt = EMAmt (St) minus EMAn

t (St) DEAt = EMAp

t (DIFt)

OSCt = DIFt minus DEAt(1)

where m = 12 n = 26 and p = 9 The weight number120572 is a fixed value equal to 2(m + 1) The number of theMACD histogram is usually called the MACD bar or OSCThe analysis process of the cross and deviation strategy of DIFand 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 positivethere is a buy signal confirmation

(iii) When DIF and DEA are negative the signal linecuts the MACD line in the downtrend and the divergenceis negative there is a sell signal confirmation

3 MACD-HVIX Weighted by HistoricalVolatility and Its Strategy

The essence of a good technical indicator is a smooth tradingstrategy ie the constructed index must be a stationaryprocess We present an empirical study in Section 5 Thevalidity and sensitivity of MACD have a strong relationshipwith the choice of parameters Different investors choosedifferent parameters to achieve the best return for differentstocks In this study the weight is based on the historicalvolatility It is expected that the accuracy and stability ofMACD can be improved The construction formula is asfollows

(EMA minus HVIX)mt (St)= sum119898119894=1 120590119905minus119894

sum119898119894=0 120590119905minus119894 (EMA minus HVIX)mtminus1 + 120590119905sum119898119894=0 120590119905minus119894 St

(t gt 1) (EMA minus HVIX)m1 = S1(MACD minus HVIX)t = (DIF minus HVIX)t

= (EMA minus HVIX)mt (St) minus (EMA minus HVIX)nt (St) (DEA minus HVIX)t = EMAp

t ((DIF minus HVIX)t) (OSC minus HVIX)t = (DIF minus HVIX)t minus (DEA minus HVIX)t

(2)

Here theweight changes over time HVIX is the change indexof the historical volatility of a stock The HVIX in this paperis the change index of the volatility in the past days It issimilar to themarket volatility indexVIX used by theChicagooptions exchange It reflects the panic of the market to acertain extent thus it is also called the panic index The aboveprocess is expressed by the code shown in Algorithm 1

The analysis process of the cross and deviation strategyof DIF-HVIX and DEA-HVIX includes the following threesteps

(i) Calculate the values of DIF-HVIX and DEA-HVIX(ii) When DIF-HVIX and DEA-HVIX are positive the

MACD-HVIX line cuts the signal line of HVIX in the

Mathematical Problems in Engineering 3

Require Set up parametersThe stock closing price is 119878119888119897119900119904119890 the historical volatility index is 119867119881119868119883 the length of the closing

stock price data is 119873119871 the weight of 119864119872119860 is119860119897119901ℎ119886 the weight of 119864119872119860 119867119881119868119883 is 119860119897119901ℎ119886 119867119881119868119883and the time parameters are m and nfor j=1 to (119873119871 minus 119898 + 1) do

sum=0for i=j to (j+119898 minus 2) do

997904rArrGenerate return series

119877119894 = log(119878119888119897119900119904119890119894+1119878119888119897119900119904119890119894 )

997904rArrSum the return in the past 119898 minus 1 dayssum=sum+119877119894

Calculate the mean return in the past 119898 minus 1 daysR mean= sum

(119898 minus 1)sum=0for i=j to (j+119898 minus 2) do

119881119886119903119894 = (119877119894 minus 119877 119898119890119886119899)2997904rArrSum the variance in the past 119898 minus 1 dayssum=sum+119881119886119903119894

Calculate the standard deviation in the past 119898 minus 1 days

119878119905119889119895 = radic 119904119906119898119898 minus 2

for j=1 to (119873119871 minus 2119898 + 2) dosum1=0for i=j to (j+119898 minus 1) dosum1=sum1+119878119905119889119894

sum2=0for i=j to (j+119898 minus 2) dosum2=sum2+119878119905119889119894

Calculate 119860119897119901ℎ119886 119867119881119868119883119860119897119901ℎ119886 119867119881119868119883119895 = 1 minus 1199041199061198982

1199041199061198981for i=2 to (119873119871 minus 2119898 + 2) do

119864119872119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886 119867119881119868119883119894minus1) times 119864119872119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886 119867119881119868119883119894minus1 times 119878119888119897119900119904119890119894+2119898minus2Calculate 119863119894119891119891 119867119881119868119883 and 119863119864119860 119867119881119868119883119863119894119891119891 119867119881119868119883 = 119864119872119860 119867119881119868119883119898 minus 119864119872119860 119867119881119868119883119899Calculate 119863119864119860 119867119881119868119883119863119864119860 119867119881119868119883(1) = sum119901119894=1 119863119868119865 119867119881119868119883

119901119860119897119901ℎ119886119898 = 2

119898 + 1for i=2 to length(119863119894119891119891 119867119881119868119883)minus119901 + 1 do

119863119864119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886119898) times 119863119864119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886119898 times 119863119894119891119891 119867119881119868119883119894+119901minus1Calculate OSC HVIXOSC HVIX = Diff HVIX minus DEA HVIX

Algorithm 1 General algorithm for HVIX and EMA-HVIX

uptrend and the divergence is positive there is a buysignal confirmation

(iii) When DIF-HVIX and DEA-HVIX are negative thesignal line of HVIX cuts the MACD-HVIX line in thedowntrend and the divergence is negative there is asell signal confirmation

4 Data Description

We first perform an empirical study on the buy-and-sellstrategy which involves buying today and selling tomorrow

We use the historical data for the stock ldquo-zgrs-rdquo fromNovember 2 2015 to September 21 2017 from the Shanghaistockmarket First we develop the strategy for the new indexand calculate the prediction accuracy and cumulative returnof the stock with two different indicators Then we comparethe accuracy rate and cumulative returnThe accuracy here iscalculated according to whether the stock price rises on thesecond day Furthermore we test a buy-and-hold strategy forthe proposed model The buy-and-hold strategy is a tradingstrategy inwhich the traders hold the stock for awhile insteadof selling it on the next trading day We use the historicaldata for the stock ldquo-dggf-rdquo from July 27 2009 to November

4 Mathematical Problems in Engineering

0 50 100 150 200 250 300 350 400 450 500date

0

0005

001

0015

002

0025

003

0035

004

0045

005

HV

IX

HVIX12HVIX26

Figure 1 Historical volatility of ldquo-zgrs-rdquo with the buy-and-sellstrategy

3 2017 from the Shanghai stock market to test a 5 d buy-and-hold strategy and use the historical data for the stock ldquo-payh-rdquo from June 22 1993 toMay 10 2010 from the Shanghaistockmarket to test a 10 d buy-and-hold strategyThe detailedtrading strategy is similar to the buy-and-sell strategy Herewe use m = 12 n = 26 and p = 95 Empirical Results

51 Empirical Results of Buy-and-Sell Strategy From the ldquo-zgrs-rdquo stock data chosen in Section 4 we calculate the HVIXof the past m days and the past n days A higher stockindex means that investors feel anxiety regarding the stockmarket and a lower stock indexmeans that the rate of changeof the stock price will decrease Figure 1 shows the HVIXindex

Next using the calculated volatility index we calculatethe weight of the EMA formula in Section 3 and obtain thevalues of MACD-HVIX DEA-HVIX and OSC

Figure 2 shows the candlestick chart and MACD his-togram In the candlestick chart the blue line representsthe 12-d EMA and the red line represents the 26-d EMACandlesticks are usually composed of a red and green bodyas well as an upper wick and a lower wick The area betweenthe opening and the closing prices is called the body andprice excursions above or below the real body are called thewick The body indicates the opening and closing prices andthe wick indicates the highest and lowest traded prices of astock during the time interval represented For a red bodythe opening price is at the bottom and the closing price is atthe top For a green body the opening price is at the top andthe closing price is at the bottom

In theMACDhistogram the solid line represents theDIFthe dotted line represents the DEA and the histogram rep-resents the MACD bar According to the strategy describedin Section 3 we buy the stock when the DIF and DEAare positive the DIF cuts the DEA in an uptrend and the

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D h

istog

ram

Sell SellBuy Buy Buy BuyBuy

DIFDEAMACD bar

Figure 2 Candlestick chart andMACDhistogram for ldquo-zgrs-rdquo withthe buy-and-sell strategy (For interpretation of the references tocolor in the figure the reader is referred to the web version of thearticle)

divergence is positive We sell the stock when the DEA cutsthe DIF in a downtrend and the divergence is negative Asshown in Figure 2 we sell the stock on days 155 and 355 andbuy the stock on days 212 290 310 381 and 393The buy-and-sell signals in the candlestick chart and theMACD histogramare shown in Figure 3

Figure 4 shows the candlestick chart and MACD his-togram of HVIX In the candlestick chart the blue linerepresents the 12-d EMA-HVIX and the red line representsthe 26-d EMA-HVIX In the MACD-HVIX histogram thesolid line represents theDIF-HVIX the dotted line representsthe DEA-HVIX and the histogram represents the MACD-HVIX bar According to the strategy described in Section 3we buy the stock when the DIF-HVIX and DEA-HVIX arepositive the DIF-HVIX cuts the DEA-HVIX in an uptrendand the divergence is positive and we sell the stock whenthe DEA-HVIX cuts the DIF-HVIX in a downtrend and thedivergence is negative As shown in Figure 4 we sell thestock on days 118 and 187 and buy the stock on days 222231 241 243 292 415 and 447 The buy-and-sell signals inthe candlestick chart and the MACD histogram are shown inFigure 5

To verify the stability of the new indicator we comparethe MACD and MACD-HVIX in Figure 6 The MACD andMACD-HVIX have basically the same trend and the stabilityof the MACD-HVIX is better than that of the MACD

Table 1 shows a comparison of the specific values ofthe buying-selling points for the MACD index and MACD-HVIX index as well as a comparison of the predicted andactual trends Here we see that the prediction accuracy ofMACD-HVIX is 0667 and that of MACD is 04286 Byusing the proposed indicator we can improve the predictionaccuracy by 5555 compared with the traditional MACDThe ldquo-Price-rdquo in the table represents the closing price of

Mathematical Problems in Engineering 5

380 385 390 395 400 405date

24

26

28

30

Cand

lesti

ck ch

art

12-day EMA 26-day EMA

380 385 390 395 400 405date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

393

340 345 350 355 360 365 370date

22

24

26

28

Cand

lesti

ck ch

art

340 345 350 355 360 365 370date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

370 375 380 385 390 395date

24

26

28

30

Cand

lesti

ck ch

art

370 375 380 385 390 395date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

381

275 280 285 290 295 300 305date

22

24

26

28

Cand

lesti

ck ch

art

275 280 285 290 295 300 305date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

295 300 305 310 315 320 325date

22

24

26

28

Cand

lesti

ck ch

art

295 300 305 310 315 320 325date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

200 205 210 215 220 225date

19

20

21

22

23

Cand

lesti

ck ch

art

200 205 210 215 220 225date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

212

12-day EMA 26-day EMA

DIF DEA MACD bar

140 145 150 155 160 165 170date

19

20

21

22

23

Cand

lesti

ck ch

art

140 145 150 155 160 165 170date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

12-day EMA 26-day EMA

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD bar

DIF DEA MACD barDIF DEA MACD bar

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD barDIF DEA MACD bar

DIF DEA MACD bar

Figure 3 Buy-and-sell signals in the candlestick chart and MACD histogram for the buy-and-sell strategy

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 2: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

2 Mathematical Problems in Engineering

Lahmiri [13] addressed the problem of technical analysisinformation fusion and reported that technical informationfusion in an NN ensemble architecture improves the predic-tion accuracy In [14] the authors argued that time seriesof stock prices are nonstationary and highly noisy This ledthe authors to propose the use of a wavelet denoising-basedbackpropagation (WDBP) NN for predicting the monthlyclosing price of the Shanghai composite index Shynkevich etal [15] investigated the impact of varying the input windowlength and the highest prediction performance was observedwhen the input window length was approximately equal tothe forecast horizon In [16] a prediction model based onthe inputoutput data plan was developed by means of theadaptive neurofuzzy inference system method representingthe fuzzy inference system Zhou et al [17] proposed a stockmarket predictionmodel based on high-frequency data usinggenerative adversarial nets Wang et al [18] used a bimodalalgorithm with a data-divider to predict the stock indexIn [19] the author used multiresolution analysis techniquesto predict the interest rate next-day variation Using K-linepatternsrsquo predictive power analysis Tao et al [20] found thattheir proposed approach can effectively improve predictionaccuracy for stock price direction and reduce forecast error

We will introduce the concept of moving average con-vergence divergence (MACD) and help the readers under-stand its principle and application in Section 2 Althoughthe MACD oscillator is one of the most popular technicalindicators it is a lagging indicator In Section 3 we proposean improved model called MACD-HVIX to deal with the lagfactor In Section 4 data for empirical research are describedFinally in Section 5 we develop a trading strategy usingMACD-HVIX and employ actual market data to verify itsvalidity and reliability We also compare the prediction accu-racy and cumulative return of the MACD-HVIX histogramwith those of the MACD histogram The performance ofMACD-HVIX exceeds that of MACDTherefore the tradingstrategy based on the MACD-HVIX index is useful fortrading 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 Itis a common indicator in stock analysis The standard MACDis the 12-day EMA subtracted by the 26-day EMA whichis also called the DIF The MACD histogram which wasdeveloped by T Aspray in 1986 measures the signed distancebetween the MACD and its signal line calculated using the9-day EMA of the MACD which is called the DEA Similarto the MACD the MACD histogram is an oscillator thatfluctuates above and below the zero line The constructionformula is as follows

EMAmt (St) = (1 minus 120572) EMAm

tminus1 + 120572 times St (t gt 1) EMAm1 = S1

MACDt = DIFt = EMAmt (St) minus EMAn

t (St) DEAt = EMAp

t (DIFt)

OSCt = DIFt minus DEAt(1)

where m = 12 n = 26 and p = 9 The weight number120572 is a fixed value equal to 2(m + 1) The number of theMACD histogram is usually called the MACD bar or OSCThe analysis process of the cross and deviation strategy of DIFand 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 positivethere is a buy signal confirmation

(iii) When DIF and DEA are negative the signal linecuts the MACD line in the downtrend and the divergenceis negative there is a sell signal confirmation

3 MACD-HVIX Weighted by HistoricalVolatility and Its Strategy

The essence of a good technical indicator is a smooth tradingstrategy ie the constructed index must be a stationaryprocess We present an empirical study in Section 5 Thevalidity and sensitivity of MACD have a strong relationshipwith the choice of parameters Different investors choosedifferent parameters to achieve the best return for differentstocks In this study the weight is based on the historicalvolatility It is expected that the accuracy and stability ofMACD can be improved The construction formula is asfollows

(EMA minus HVIX)mt (St)= sum119898119894=1 120590119905minus119894

sum119898119894=0 120590119905minus119894 (EMA minus HVIX)mtminus1 + 120590119905sum119898119894=0 120590119905minus119894 St

(t gt 1) (EMA minus HVIX)m1 = S1(MACD minus HVIX)t = (DIF minus HVIX)t

= (EMA minus HVIX)mt (St) minus (EMA minus HVIX)nt (St) (DEA minus HVIX)t = EMAp

t ((DIF minus HVIX)t) (OSC minus HVIX)t = (DIF minus HVIX)t minus (DEA minus HVIX)t

(2)

Here theweight changes over time HVIX is the change indexof the historical volatility of a stock The HVIX in this paperis the change index of the volatility in the past days It issimilar to themarket volatility indexVIX used by theChicagooptions exchange It reflects the panic of the market to acertain extent thus it is also called the panic index The aboveprocess is expressed by the code shown in Algorithm 1

The analysis process of the cross and deviation strategyof DIF-HVIX and DEA-HVIX includes the following threesteps

(i) Calculate the values of DIF-HVIX and DEA-HVIX(ii) When DIF-HVIX and DEA-HVIX are positive the

MACD-HVIX line cuts the signal line of HVIX in the

Mathematical Problems in Engineering 3

Require Set up parametersThe stock closing price is 119878119888119897119900119904119890 the historical volatility index is 119867119881119868119883 the length of the closing

stock price data is 119873119871 the weight of 119864119872119860 is119860119897119901ℎ119886 the weight of 119864119872119860 119867119881119868119883 is 119860119897119901ℎ119886 119867119881119868119883and the time parameters are m and nfor j=1 to (119873119871 minus 119898 + 1) do

sum=0for i=j to (j+119898 minus 2) do

997904rArrGenerate return series

119877119894 = log(119878119888119897119900119904119890119894+1119878119888119897119900119904119890119894 )

997904rArrSum the return in the past 119898 minus 1 dayssum=sum+119877119894

Calculate the mean return in the past 119898 minus 1 daysR mean= sum

(119898 minus 1)sum=0for i=j to (j+119898 minus 2) do

119881119886119903119894 = (119877119894 minus 119877 119898119890119886119899)2997904rArrSum the variance in the past 119898 minus 1 dayssum=sum+119881119886119903119894

Calculate the standard deviation in the past 119898 minus 1 days

119878119905119889119895 = radic 119904119906119898119898 minus 2

for j=1 to (119873119871 minus 2119898 + 2) dosum1=0for i=j to (j+119898 minus 1) dosum1=sum1+119878119905119889119894

sum2=0for i=j to (j+119898 minus 2) dosum2=sum2+119878119905119889119894

Calculate 119860119897119901ℎ119886 119867119881119868119883119860119897119901ℎ119886 119867119881119868119883119895 = 1 minus 1199041199061198982

1199041199061198981for i=2 to (119873119871 minus 2119898 + 2) do

119864119872119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886 119867119881119868119883119894minus1) times 119864119872119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886 119867119881119868119883119894minus1 times 119878119888119897119900119904119890119894+2119898minus2Calculate 119863119894119891119891 119867119881119868119883 and 119863119864119860 119867119881119868119883119863119894119891119891 119867119881119868119883 = 119864119872119860 119867119881119868119883119898 minus 119864119872119860 119867119881119868119883119899Calculate 119863119864119860 119867119881119868119883119863119864119860 119867119881119868119883(1) = sum119901119894=1 119863119868119865 119867119881119868119883

119901119860119897119901ℎ119886119898 = 2

119898 + 1for i=2 to length(119863119894119891119891 119867119881119868119883)minus119901 + 1 do

119863119864119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886119898) times 119863119864119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886119898 times 119863119894119891119891 119867119881119868119883119894+119901minus1Calculate OSC HVIXOSC HVIX = Diff HVIX minus DEA HVIX

Algorithm 1 General algorithm for HVIX and EMA-HVIX

uptrend and the divergence is positive there is a buysignal confirmation

(iii) When DIF-HVIX and DEA-HVIX are negative thesignal line of HVIX cuts the MACD-HVIX line in thedowntrend and the divergence is negative there is asell signal confirmation

4 Data Description

We first perform an empirical study on the buy-and-sellstrategy which involves buying today and selling tomorrow

We use the historical data for the stock ldquo-zgrs-rdquo fromNovember 2 2015 to September 21 2017 from the Shanghaistockmarket First we develop the strategy for the new indexand calculate the prediction accuracy and cumulative returnof the stock with two different indicators Then we comparethe accuracy rate and cumulative returnThe accuracy here iscalculated according to whether the stock price rises on thesecond day Furthermore we test a buy-and-hold strategy forthe proposed model The buy-and-hold strategy is a tradingstrategy inwhich the traders hold the stock for awhile insteadof selling it on the next trading day We use the historicaldata for the stock ldquo-dggf-rdquo from July 27 2009 to November

4 Mathematical Problems in Engineering

0 50 100 150 200 250 300 350 400 450 500date

0

0005

001

0015

002

0025

003

0035

004

0045

005

HV

IX

HVIX12HVIX26

Figure 1 Historical volatility of ldquo-zgrs-rdquo with the buy-and-sellstrategy

3 2017 from the Shanghai stock market to test a 5 d buy-and-hold strategy and use the historical data for the stock ldquo-payh-rdquo from June 22 1993 toMay 10 2010 from the Shanghaistockmarket to test a 10 d buy-and-hold strategyThe detailedtrading strategy is similar to the buy-and-sell strategy Herewe use m = 12 n = 26 and p = 95 Empirical Results

51 Empirical Results of Buy-and-Sell Strategy From the ldquo-zgrs-rdquo stock data chosen in Section 4 we calculate the HVIXof the past m days and the past n days A higher stockindex means that investors feel anxiety regarding the stockmarket and a lower stock indexmeans that the rate of changeof the stock price will decrease Figure 1 shows the HVIXindex

Next using the calculated volatility index we calculatethe weight of the EMA formula in Section 3 and obtain thevalues of MACD-HVIX DEA-HVIX and OSC

Figure 2 shows the candlestick chart and MACD his-togram In the candlestick chart the blue line representsthe 12-d EMA and the red line represents the 26-d EMACandlesticks are usually composed of a red and green bodyas well as an upper wick and a lower wick The area betweenthe opening and the closing prices is called the body andprice excursions above or below the real body are called thewick The body indicates the opening and closing prices andthe wick indicates the highest and lowest traded prices of astock during the time interval represented For a red bodythe opening price is at the bottom and the closing price is atthe top For a green body the opening price is at the top andthe closing price is at the bottom

In theMACDhistogram the solid line represents theDIFthe dotted line represents the DEA and the histogram rep-resents the MACD bar According to the strategy describedin Section 3 we buy the stock when the DIF and DEAare positive the DIF cuts the DEA in an uptrend and the

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D h

istog

ram

Sell SellBuy Buy Buy BuyBuy

DIFDEAMACD bar

Figure 2 Candlestick chart andMACDhistogram for ldquo-zgrs-rdquo withthe buy-and-sell strategy (For interpretation of the references tocolor in the figure the reader is referred to the web version of thearticle)

divergence is positive We sell the stock when the DEA cutsthe DIF in a downtrend and the divergence is negative Asshown in Figure 2 we sell the stock on days 155 and 355 andbuy the stock on days 212 290 310 381 and 393The buy-and-sell signals in the candlestick chart and theMACD histogramare shown in Figure 3

Figure 4 shows the candlestick chart and MACD his-togram of HVIX In the candlestick chart the blue linerepresents the 12-d EMA-HVIX and the red line representsthe 26-d EMA-HVIX In the MACD-HVIX histogram thesolid line represents theDIF-HVIX the dotted line representsthe DEA-HVIX and the histogram represents the MACD-HVIX bar According to the strategy described in Section 3we buy the stock when the DIF-HVIX and DEA-HVIX arepositive the DIF-HVIX cuts the DEA-HVIX in an uptrendand the divergence is positive and we sell the stock whenthe DEA-HVIX cuts the DIF-HVIX in a downtrend and thedivergence is negative As shown in Figure 4 we sell thestock on days 118 and 187 and buy the stock on days 222231 241 243 292 415 and 447 The buy-and-sell signals inthe candlestick chart and the MACD histogram are shown inFigure 5

To verify the stability of the new indicator we comparethe MACD and MACD-HVIX in Figure 6 The MACD andMACD-HVIX have basically the same trend and the stabilityof the MACD-HVIX is better than that of the MACD

Table 1 shows a comparison of the specific values ofthe buying-selling points for the MACD index and MACD-HVIX index as well as a comparison of the predicted andactual trends Here we see that the prediction accuracy ofMACD-HVIX is 0667 and that of MACD is 04286 Byusing the proposed indicator we can improve the predictionaccuracy by 5555 compared with the traditional MACDThe ldquo-Price-rdquo in the table represents the closing price of

Mathematical Problems in Engineering 5

380 385 390 395 400 405date

24

26

28

30

Cand

lesti

ck ch

art

12-day EMA 26-day EMA

380 385 390 395 400 405date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

393

340 345 350 355 360 365 370date

22

24

26

28

Cand

lesti

ck ch

art

340 345 350 355 360 365 370date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

370 375 380 385 390 395date

24

26

28

30

Cand

lesti

ck ch

art

370 375 380 385 390 395date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

381

275 280 285 290 295 300 305date

22

24

26

28

Cand

lesti

ck ch

art

275 280 285 290 295 300 305date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

295 300 305 310 315 320 325date

22

24

26

28

Cand

lesti

ck ch

art

295 300 305 310 315 320 325date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

200 205 210 215 220 225date

19

20

21

22

23

Cand

lesti

ck ch

art

200 205 210 215 220 225date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

212

12-day EMA 26-day EMA

DIF DEA MACD bar

140 145 150 155 160 165 170date

19

20

21

22

23

Cand

lesti

ck ch

art

140 145 150 155 160 165 170date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

12-day EMA 26-day EMA

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD bar

DIF DEA MACD barDIF DEA MACD bar

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD barDIF DEA MACD bar

DIF DEA MACD bar

Figure 3 Buy-and-sell signals in the candlestick chart and MACD histogram for the buy-and-sell strategy

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 3: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Mathematical Problems in Engineering 3

Require Set up parametersThe stock closing price is 119878119888119897119900119904119890 the historical volatility index is 119867119881119868119883 the length of the closing

stock price data is 119873119871 the weight of 119864119872119860 is119860119897119901ℎ119886 the weight of 119864119872119860 119867119881119868119883 is 119860119897119901ℎ119886 119867119881119868119883and the time parameters are m and nfor j=1 to (119873119871 minus 119898 + 1) do

sum=0for i=j to (j+119898 minus 2) do

997904rArrGenerate return series

119877119894 = log(119878119888119897119900119904119890119894+1119878119888119897119900119904119890119894 )

997904rArrSum the return in the past 119898 minus 1 dayssum=sum+119877119894

Calculate the mean return in the past 119898 minus 1 daysR mean= sum

(119898 minus 1)sum=0for i=j to (j+119898 minus 2) do

119881119886119903119894 = (119877119894 minus 119877 119898119890119886119899)2997904rArrSum the variance in the past 119898 minus 1 dayssum=sum+119881119886119903119894

Calculate the standard deviation in the past 119898 minus 1 days

119878119905119889119895 = radic 119904119906119898119898 minus 2

for j=1 to (119873119871 minus 2119898 + 2) dosum1=0for i=j to (j+119898 minus 1) dosum1=sum1+119878119905119889119894

sum2=0for i=j to (j+119898 minus 2) dosum2=sum2+119878119905119889119894

Calculate 119860119897119901ℎ119886 119867119881119868119883119860119897119901ℎ119886 119867119881119868119883119895 = 1 minus 1199041199061198982

1199041199061198981for i=2 to (119873119871 minus 2119898 + 2) do

119864119872119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886 119867119881119868119883119894minus1) times 119864119872119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886 119867119881119868119883119894minus1 times 119878119888119897119900119904119890119894+2119898minus2Calculate 119863119894119891119891 119867119881119868119883 and 119863119864119860 119867119881119868119883119863119894119891119891 119867119881119868119883 = 119864119872119860 119867119881119868119883119898 minus 119864119872119860 119867119881119868119883119899Calculate 119863119864119860 119867119881119868119883119863119864119860 119867119881119868119883(1) = sum119901119894=1 119863119868119865 119867119881119868119883

119901119860119897119901ℎ119886119898 = 2

119898 + 1for i=2 to length(119863119894119891119891 119867119881119868119883)minus119901 + 1 do

119863119864119860 119867119881119868119883119894 = (1 minus 119860119897119901ℎ119886119898) times 119863119864119860 119867119881119868119883119894minus1 + 119860119897119901ℎ119886119898 times 119863119894119891119891 119867119881119868119883119894+119901minus1Calculate OSC HVIXOSC HVIX = Diff HVIX minus DEA HVIX

Algorithm 1 General algorithm for HVIX and EMA-HVIX

uptrend and the divergence is positive there is a buysignal confirmation

(iii) When DIF-HVIX and DEA-HVIX are negative thesignal line of HVIX cuts the MACD-HVIX line in thedowntrend and the divergence is negative there is asell signal confirmation

4 Data Description

We first perform an empirical study on the buy-and-sellstrategy which involves buying today and selling tomorrow

We use the historical data for the stock ldquo-zgrs-rdquo fromNovember 2 2015 to September 21 2017 from the Shanghaistockmarket First we develop the strategy for the new indexand calculate the prediction accuracy and cumulative returnof the stock with two different indicators Then we comparethe accuracy rate and cumulative returnThe accuracy here iscalculated according to whether the stock price rises on thesecond day Furthermore we test a buy-and-hold strategy forthe proposed model The buy-and-hold strategy is a tradingstrategy inwhich the traders hold the stock for awhile insteadof selling it on the next trading day We use the historicaldata for the stock ldquo-dggf-rdquo from July 27 2009 to November

4 Mathematical Problems in Engineering

0 50 100 150 200 250 300 350 400 450 500date

0

0005

001

0015

002

0025

003

0035

004

0045

005

HV

IX

HVIX12HVIX26

Figure 1 Historical volatility of ldquo-zgrs-rdquo with the buy-and-sellstrategy

3 2017 from the Shanghai stock market to test a 5 d buy-and-hold strategy and use the historical data for the stock ldquo-payh-rdquo from June 22 1993 toMay 10 2010 from the Shanghaistockmarket to test a 10 d buy-and-hold strategyThe detailedtrading strategy is similar to the buy-and-sell strategy Herewe use m = 12 n = 26 and p = 95 Empirical Results

51 Empirical Results of Buy-and-Sell Strategy From the ldquo-zgrs-rdquo stock data chosen in Section 4 we calculate the HVIXof the past m days and the past n days A higher stockindex means that investors feel anxiety regarding the stockmarket and a lower stock indexmeans that the rate of changeof the stock price will decrease Figure 1 shows the HVIXindex

Next using the calculated volatility index we calculatethe weight of the EMA formula in Section 3 and obtain thevalues of MACD-HVIX DEA-HVIX and OSC

Figure 2 shows the candlestick chart and MACD his-togram In the candlestick chart the blue line representsthe 12-d EMA and the red line represents the 26-d EMACandlesticks are usually composed of a red and green bodyas well as an upper wick and a lower wick The area betweenthe opening and the closing prices is called the body andprice excursions above or below the real body are called thewick The body indicates the opening and closing prices andthe wick indicates the highest and lowest traded prices of astock during the time interval represented For a red bodythe opening price is at the bottom and the closing price is atthe top For a green body the opening price is at the top andthe closing price is at the bottom

In theMACDhistogram the solid line represents theDIFthe dotted line represents the DEA and the histogram rep-resents the MACD bar According to the strategy describedin Section 3 we buy the stock when the DIF and DEAare positive the DIF cuts the DEA in an uptrend and the

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D h

istog

ram

Sell SellBuy Buy Buy BuyBuy

DIFDEAMACD bar

Figure 2 Candlestick chart andMACDhistogram for ldquo-zgrs-rdquo withthe buy-and-sell strategy (For interpretation of the references tocolor in the figure the reader is referred to the web version of thearticle)

divergence is positive We sell the stock when the DEA cutsthe DIF in a downtrend and the divergence is negative Asshown in Figure 2 we sell the stock on days 155 and 355 andbuy the stock on days 212 290 310 381 and 393The buy-and-sell signals in the candlestick chart and theMACD histogramare shown in Figure 3

Figure 4 shows the candlestick chart and MACD his-togram of HVIX In the candlestick chart the blue linerepresents the 12-d EMA-HVIX and the red line representsthe 26-d EMA-HVIX In the MACD-HVIX histogram thesolid line represents theDIF-HVIX the dotted line representsthe DEA-HVIX and the histogram represents the MACD-HVIX bar According to the strategy described in Section 3we buy the stock when the DIF-HVIX and DEA-HVIX arepositive the DIF-HVIX cuts the DEA-HVIX in an uptrendand the divergence is positive and we sell the stock whenthe DEA-HVIX cuts the DIF-HVIX in a downtrend and thedivergence is negative As shown in Figure 4 we sell thestock on days 118 and 187 and buy the stock on days 222231 241 243 292 415 and 447 The buy-and-sell signals inthe candlestick chart and the MACD histogram are shown inFigure 5

To verify the stability of the new indicator we comparethe MACD and MACD-HVIX in Figure 6 The MACD andMACD-HVIX have basically the same trend and the stabilityof the MACD-HVIX is better than that of the MACD

Table 1 shows a comparison of the specific values ofthe buying-selling points for the MACD index and MACD-HVIX index as well as a comparison of the predicted andactual trends Here we see that the prediction accuracy ofMACD-HVIX is 0667 and that of MACD is 04286 Byusing the proposed indicator we can improve the predictionaccuracy by 5555 compared with the traditional MACDThe ldquo-Price-rdquo in the table represents the closing price of

Mathematical Problems in Engineering 5

380 385 390 395 400 405date

24

26

28

30

Cand

lesti

ck ch

art

12-day EMA 26-day EMA

380 385 390 395 400 405date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

393

340 345 350 355 360 365 370date

22

24

26

28

Cand

lesti

ck ch

art

340 345 350 355 360 365 370date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

370 375 380 385 390 395date

24

26

28

30

Cand

lesti

ck ch

art

370 375 380 385 390 395date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

381

275 280 285 290 295 300 305date

22

24

26

28

Cand

lesti

ck ch

art

275 280 285 290 295 300 305date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

295 300 305 310 315 320 325date

22

24

26

28

Cand

lesti

ck ch

art

295 300 305 310 315 320 325date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

200 205 210 215 220 225date

19

20

21

22

23

Cand

lesti

ck ch

art

200 205 210 215 220 225date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

212

12-day EMA 26-day EMA

DIF DEA MACD bar

140 145 150 155 160 165 170date

19

20

21

22

23

Cand

lesti

ck ch

art

140 145 150 155 160 165 170date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

12-day EMA 26-day EMA

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD bar

DIF DEA MACD barDIF DEA MACD bar

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD barDIF DEA MACD bar

DIF DEA MACD bar

Figure 3 Buy-and-sell signals in the candlestick chart and MACD histogram for the buy-and-sell strategy

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 4: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

4 Mathematical Problems in Engineering

0 50 100 150 200 250 300 350 400 450 500date

0

0005

001

0015

002

0025

003

0035

004

0045

005

HV

IX

HVIX12HVIX26

Figure 1 Historical volatility of ldquo-zgrs-rdquo with the buy-and-sellstrategy

3 2017 from the Shanghai stock market to test a 5 d buy-and-hold strategy and use the historical data for the stock ldquo-payh-rdquo from June 22 1993 toMay 10 2010 from the Shanghaistockmarket to test a 10 d buy-and-hold strategyThe detailedtrading strategy is similar to the buy-and-sell strategy Herewe use m = 12 n = 26 and p = 95 Empirical Results

51 Empirical Results of Buy-and-Sell Strategy From the ldquo-zgrs-rdquo stock data chosen in Section 4 we calculate the HVIXof the past m days and the past n days A higher stockindex means that investors feel anxiety regarding the stockmarket and a lower stock indexmeans that the rate of changeof the stock price will decrease Figure 1 shows the HVIXindex

Next using the calculated volatility index we calculatethe weight of the EMA formula in Section 3 and obtain thevalues of MACD-HVIX DEA-HVIX and OSC

Figure 2 shows the candlestick chart and MACD his-togram In the candlestick chart the blue line representsthe 12-d EMA and the red line represents the 26-d EMACandlesticks are usually composed of a red and green bodyas well as an upper wick and a lower wick The area betweenthe opening and the closing prices is called the body andprice excursions above or below the real body are called thewick The body indicates the opening and closing prices andthe wick indicates the highest and lowest traded prices of astock during the time interval represented For a red bodythe opening price is at the bottom and the closing price is atthe top For a green body the opening price is at the top andthe closing price is at the bottom

In theMACDhistogram the solid line represents theDIFthe dotted line represents the DEA and the histogram rep-resents the MACD bar According to the strategy describedin Section 3 we buy the stock when the DIF and DEAare positive the DIF cuts the DEA in an uptrend and the

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D h

istog

ram

Sell SellBuy Buy Buy BuyBuy

DIFDEAMACD bar

Figure 2 Candlestick chart andMACDhistogram for ldquo-zgrs-rdquo withthe buy-and-sell strategy (For interpretation of the references tocolor in the figure the reader is referred to the web version of thearticle)

divergence is positive We sell the stock when the DEA cutsthe DIF in a downtrend and the divergence is negative Asshown in Figure 2 we sell the stock on days 155 and 355 andbuy the stock on days 212 290 310 381 and 393The buy-and-sell signals in the candlestick chart and theMACD histogramare shown in Figure 3

Figure 4 shows the candlestick chart and MACD his-togram of HVIX In the candlestick chart the blue linerepresents the 12-d EMA-HVIX and the red line representsthe 26-d EMA-HVIX In the MACD-HVIX histogram thesolid line represents theDIF-HVIX the dotted line representsthe DEA-HVIX and the histogram represents the MACD-HVIX bar According to the strategy described in Section 3we buy the stock when the DIF-HVIX and DEA-HVIX arepositive the DIF-HVIX cuts the DEA-HVIX in an uptrendand the divergence is positive and we sell the stock whenthe DEA-HVIX cuts the DIF-HVIX in a downtrend and thedivergence is negative As shown in Figure 4 we sell thestock on days 118 and 187 and buy the stock on days 222231 241 243 292 415 and 447 The buy-and-sell signals inthe candlestick chart and the MACD histogram are shown inFigure 5

To verify the stability of the new indicator we comparethe MACD and MACD-HVIX in Figure 6 The MACD andMACD-HVIX have basically the same trend and the stabilityof the MACD-HVIX is better than that of the MACD

Table 1 shows a comparison of the specific values ofthe buying-selling points for the MACD index and MACD-HVIX index as well as a comparison of the predicted andactual trends Here we see that the prediction accuracy ofMACD-HVIX is 0667 and that of MACD is 04286 Byusing the proposed indicator we can improve the predictionaccuracy by 5555 compared with the traditional MACDThe ldquo-Price-rdquo in the table represents the closing price of

Mathematical Problems in Engineering 5

380 385 390 395 400 405date

24

26

28

30

Cand

lesti

ck ch

art

12-day EMA 26-day EMA

380 385 390 395 400 405date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

393

340 345 350 355 360 365 370date

22

24

26

28

Cand

lesti

ck ch

art

340 345 350 355 360 365 370date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

370 375 380 385 390 395date

24

26

28

30

Cand

lesti

ck ch

art

370 375 380 385 390 395date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

381

275 280 285 290 295 300 305date

22

24

26

28

Cand

lesti

ck ch

art

275 280 285 290 295 300 305date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

295 300 305 310 315 320 325date

22

24

26

28

Cand

lesti

ck ch

art

295 300 305 310 315 320 325date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

200 205 210 215 220 225date

19

20

21

22

23

Cand

lesti

ck ch

art

200 205 210 215 220 225date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

212

12-day EMA 26-day EMA

DIF DEA MACD bar

140 145 150 155 160 165 170date

19

20

21

22

23

Cand

lesti

ck ch

art

140 145 150 155 160 165 170date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

12-day EMA 26-day EMA

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD bar

DIF DEA MACD barDIF DEA MACD bar

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD barDIF DEA MACD bar

DIF DEA MACD bar

Figure 3 Buy-and-sell signals in the candlestick chart and MACD histogram for the buy-and-sell strategy

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 5: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Mathematical Problems in Engineering 5

380 385 390 395 400 405date

24

26

28

30

Cand

lesti

ck ch

art

12-day EMA 26-day EMA

380 385 390 395 400 405date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

393

340 345 350 355 360 365 370date

22

24

26

28

Cand

lesti

ck ch

art

340 345 350 355 360 365 370date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

370 375 380 385 390 395date

24

26

28

30

Cand

lesti

ck ch

art

370 375 380 385 390 395date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

381

275 280 285 290 295 300 305date

22

24

26

28

Cand

lesti

ck ch

art

275 280 285 290 295 300 305date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

295 300 305 310 315 320 325date

22

24

26

28

Cand

lesti

ck ch

art

295 300 305 310 315 320 325date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

200 205 210 215 220 225date

19

20

21

22

23

Cand

lesti

ck ch

art

200 205 210 215 220 225date

minus2

minus1

0

1

MA

CD h

istog

ram

Buy

212

12-day EMA 26-day EMA

DIF DEA MACD bar

140 145 150 155 160 165 170date

19

20

21

22

23

Cand

lesti

ck ch

art

140 145 150 155 160 165 170date

minus2

minus1

0

1

MA

CD h

istog

ram

Sell

12-day EMA 26-day EMA

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD bar

DIF DEA MACD barDIF DEA MACD bar

12-day EMA 26-day EMA12-day EMA 26-day EMA

DIF DEA MACD barDIF DEA MACD bar

DIF DEA MACD bar

Figure 3 Buy-and-sell signals in the candlestick chart and MACD histogram for the buy-and-sell strategy

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 6: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

6 Mathematical Problems in Engineering

Table 1 Comparison of the specific values of the buying-selling points for the buy-and-sell strategy

Test date Price (Test date) Price (Test date + 1 d) Predicted trend Actual trend

MACD

155 2039 2042 darr uarr212 2182 2193 uarr uarr290 2532 2538 uarr uarr310 2644 2650 uarr uarr355 2451 2462 darr uarr381 2793 2745 uarr darr393 2900 2848 uarr darr

Win rate 04286

MACD-HVIX

118 2224 2190 darr darr187 2080 2066 darr darr222 2190 2184 uarr darr231 2180 2167 uarr darr241 2165 2158 uarr darr243 2178 2183 uarr uarr292 2518 2558 uarr uarr415 2798 2880 uarr uarr447 2927 2951 uarr uarr

Win rate 06667

0 50 100 150 200 250 300 350 400 450date

20

25

30

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 50 100 150 200 250 300 350 400 450date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell Sell BuyBuyBuy

Buy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 4 Candlestick chart and MACD-HVIX histogram for ldquo-zgrs-rdquo with the buy-and-sell strategy (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

stock Next we compare the cumulative returns for the twoindicators According to the trading points shown in the tablewe perform a simulation test We assume that the initial fundis 1 million The cumulative returns under the two indexesare 11136 million and 13365million for MACD and MACD-HVIX indices respectively

52 Empirical Results of Buy-and-Hold Strategy Using the ldquo-dggf-rdquo stock data chosen in Section 4 we first investigate thebuy or sell points for both the indicators with the buy-and-hold strategy applied for 5 dThenwe compare the predictionaccuracy between the two indicators The MACD histogramshown in Figure 7 indicates the buy-and-sell points weshould buy the stock at a buy point on days 391 1071 11811326 and 1481 and sell the stock at a sell point on days 791881 and 911The prediction situation is shown in Table 2

The MACD-HVIX histogram in Figure 8 indicates thebuy-and-sell points We should buy the stock at a buy pointon days 371 1201 1331 and 1561 and sell the stock at a sellpoint on days 751 and 771 The prediction situation is shownin Table 2 A comparison between MACD andMACD-HVIXis shown in Figure 9

Table 2 shows a comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy for 5 d as well asa comparison of the predicted and actual trends Here weobserve that the prediction accuracy of MACD-HVIX is08333 and that of MACD is 06250 By using the proposedindicator we can improve the prediction accuracy by 3333compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

Next using the ldquo-payh-rdquo stock data chosen in Section 4we investigate the buy or sell points for both the indicatorswith the buy-and-hold strategy applied for 10d Then wecompare the prediction accuracy between the two indicatorsTheMACD histogram in Figure 10 indicates the buy-and-sellpoints We should buy the stock at a buy point on day 901and sell the stock at a sell point on days 621 1971 2071 22912431 and 2661 The prediction situation is shown in Table 3

The MACD-HVIX histogram in Figure 11 indicates thebuy-and-sell points We should buy the stock at a buy point

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 7: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Mathematical Problems in Engineering 7

105 110 115 120 125 130date

18

20

22

24Ca

ndle

stick

char

t

12-day EMA-HVIX26-day EMA-HVIX

105 110 115 120 125 130date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

118

DIF-HVIXDEA-HVIXMACD-HVIX bar

12-day EMA-HVIX26-day EMA-HVIX

175 180 185 190 195 200date

18

20

22

24

Cand

lesti

ck ch

art

DIF-HVIXDEA-HVIXMACD-HVIX bar

175 180 185 190 195 200date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Sell

187

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

210 235230225220215date

210 235230225220215date

18

20

22

24

Cand

lesti

ck ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

222

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

220 245240235230225date

220 245240235230225date

18

20

22

24Ca

ndle

stick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

231

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

243230 255250245240235

230 255250245240235

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

18

20

22

24

Cand

lesti

ck ch

art

230 255250245240235date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

241

230 255250245240235

Figure 5 Continued

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 8: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

8 Mathematical Problems in Engineering

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

435 460455450445440date

435 460455450445440date

22

24

26

28

30

Cand

lestic

k ch

art

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

447

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

280 305300295290285date

20

22

24

26

28Ca

ndles

tick

char

t

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

292280 305300295290285date

12-day EMA-HVIX26-day EMA-HVIX

DIF-HVIXDEA-HVIXMACD-HVIX bar

date

22

24

26

28

30

Cand

lestic

k ch

art

400 430425420415410405date

minus2

minus1

0

1

MAC

D-H

VIX

hist

ogra

m

Buy

400 430425420415410405

Figure 5 Buy-and-sell signals in the candlestick chart and the MACD-HVIX histogram for the buy-and-sell strategy

on day 901 and sell the stock at a sell point on days 2071 24212661 and 2741The prediction situation is shown in Table 3A comparison of MACD and MACD-HVIX is presented inFigure 12

Table 3 shows the comparison of the specific values ofthe buying-selling points for the MACD and MACD-HVIXindices with the buy-and-hold strategy applied for 5 d as wellas a comparison of the predicted and actual trends Herewe observe that the prediction accuracy of MACD-HVIXis 08 and that of MACD is 07143 By using the proposedindicator we can improve the prediction accuracy by 12compared with the traditional MACD The ldquo-Price-rdquo in thetable represents the closing price of the stock

53 Computational Complexity Thecomputational complex-ity of the MACD and MACD-HVIX for a stock which

has a length of n are 119874(119873) and 119874(1198732) respectively Interms of trend prediction processing time the average timerequired to process a buy-and-sell strategy a buy-and-holdstrategy for 5 days and a buy-and-hold strategy for 10 dayswith the MACD approach (MACD-HVIX) are respectively125 (151) 112 (135) and 141 seconds (158) using MatlabR2017b on an Intel(R) Core(TM) i5-6200 CPU 230GHzprocessor

6 Conclusion

As indicated by Tables 1 2 and 3 we buy-and-sell stock basedon improvedMACD then we found all the accuracy is higherthan that before the improvement Therefore the improvedmodel has higher maneuverability in securities investmentand allows investors to capture every buy-and-sell points in

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 9: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Mathematical Problems in Engineering 9

Table 2 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 5 d

Test date Price (Test date) Price (Test date + 5 d) Predicted trend Actual trend

MACD

391 1304 1570 uarr uarr791 481 519 darr uarr881 555 561 darr uarr911 571 559 darr darr1071 657 674 uarr uarr1181 666 695 uarr uarr1326 1070 1193 uarr uarr1481 1728 1351 uarr darr

Win rate 06250

MACD-HVIX

371 1168 1200 uarr uarr751 553 575 darr uarr771 576 562 darr darr1201 766 783 uarr uarr1331 1193 1223 uarr uarr1561 1689 1905 uarr uarr

Win rate 08333

MACD barMACD-HVIX bar

minus06

minus04

minus02

0

02

04

06

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

50 100 150 200 250 300 350 400 450 5000date

Figure 6 Comparison of the two indicators for the buy-and-sellstrategy

the market For both the buy-and-sell strategy and the buy-and-hold strategy the empirical results indicated that theproposed model can make more precise predictions thanthe traditional model The proposed model was tested withthree different stocks and it generated the high predictionaccuracy for all the cases In addition while a smoothingindex is used to construct theMACD index and the impact ofthe past price declines exponentially the MACD-HVIX doesnot have this property Although the MACD-HVIX index isimproved compared with the MACD index the stationarityof the MACD-HVIX index is difficult prove theoreticallyTest shows that it is stable however in the ever-changingmarket an abnormal situation can cause incalculable losses to

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MAC

D h

istog

ram

Sell SellSell

Buy Buy Buy Buy Buy

DIFDEAMACD bar

Figure 7 Candlestick chart andMACDhistogram for ldquo-dggf-rdquo withthe buy-and-hold strategy applied for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the webversion of the article)

investors In future research we will investigate other factorsfor themodel by constantly updating the data and the trainingmodel to obtain a better prediction effect

Data Availability

The data used to support the findings of this study areavailable from the corresponding author upon request

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 10: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

10 Mathematical Problems in Engineering

Table 3 Comparison of the specific values of the buying-selling points with the buy-and-hold strategy applied for 10 d

Test date Price (Test date) Price (Test date + 10 d) Predicted trend Actual trend

MACD

621 659 623 darr darr901 1887 1905 uarr uarr1971 1305 1322 darr uarr2071 1225 1031 darr darr2291 1111 1052 darr darr2431 1056 1081 darr uarr2661 851 823 darr darr

Win rate 07143

MACD-HVIX

901 1887 1905 uarr uarr2071 1225 1031 darr darr2421 1130 1056 darr darr2661 851 823 darr darr2741 695 719 darr uarr

Win rate 08000

0 200 400 600 800 1000 1200 1400 1600 1800date

0

10

20

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 200 400 600 800 1000 1200 1400 1600 1800date

minus2

0

2

4

MA

CD-H

VIX

hist

ogra

m

Sell SellBuy Buy Buy Buy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 8 Candlestick chart and MACD-HVIX histogram for ldquo-dggf-rdquo with the buy-and-hold strategy for 5 d (For interpretation of thereferences to color in this figure the reader is referred to the web version of the article)

0 200 400 600 800 1000 1200 1400 1600 1800 2000date

minus15

minus1

minus05

0

05

1

15

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 9 Comparison of the two indicators with the buy-and-hold strategy applied for 5 d

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 11: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Mathematical Problems in Engineering 11

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA26-day EMA

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD h

istog

ram

Se ll Sell Sell Sell Sell SellBuy

DIFDEAMACD bar

Figure 10 Candlestick chart and MACD histogram for ldquo-payh-rdquowith the buy-and-hold strategy applied for 10 d (For interpretationof the references to color in this figure the reader is referred to theweb version of the article)

0 500 1000 1500 2000 2500 3000 3500 4000date

0

20

40

Cand

lesti

ck ch

art

12-day EMA-HVIX26-day EMA-HVIX

0 500 1000 1500 2000 2500 3000 3500 4000date

minus5

0

5

10

MA

CD-H

VIX

hist

ogra

m

Sell Sell Sell SellBuy

DIF-HVIXDEA-HVIXMACD-HVIX bar

Figure 11 Candlestick chart and MACD-HVIX histogram forldquo-payh-rdquo with the buy-and-hold strategy applied for 10 d (Forinterpretation of the references to color in this figure the reader isreferred to the web version of the article)

Conflicts of Interest

The authors declare that there are no conflicts of interestregarding the publication of this paper

Acknowledgments

The first author (Jian Wang) was supported by the ChinaScholarship Council (201808260026) The corresponding

0 500 1000 1500 2000 2500 3000 3500 4000 4500date

minus3

minus2

minus1

0

1

2

3

MAC

D b

ar an

d M

ACD

-HV

IX b

ar

MACD barMACD-HVIX bar

Figure 12 Comparison of the two indicatorswith the buy-and-holdstrategy applied for 10 d

author (JS Kim) expresses thanks for the support from theBK21 PLUS program

References

[1] F Schmitt D Schertzer and S Lovejoy ldquoMultifractal Fluc-tuations in Financerdquo International Journal of eoretical andApplied Finance vol 03 no 03 pp 361ndash364 2000

[2] T J Moskowitz Y H Ooi and L H Pedersen ldquoTime seriesmomentumrdquo Journal of Financial Economics vol 104 no 2 pp228ndash250 2012

[3] C S Asness T J Moskowitz and L H Pedersen ldquoValue andMomentum Everywhererdquo Journal of Finance vol 68 no 3 pp929ndash985 2013

[4] M R Hassan ldquoA combination of hidden Markov model andfuzzymodel for stockmarket forecastingrdquoNeurocomputing vol72 no 16-18 pp 3439ndash3446 2009

[5] P Pai L Hong and K Lin ldquoUsing Internet Search Trendsand Historical Trading Data for Predicting Stock Markets bythe Least Squares Support Vector Regression Modelrdquo Com-putational Intelligence and Neuroscience vol 2018 Article ID6305246 15 pages 2018

[6] S Lahmiri ldquoMinute-ahead stock price forecasting based onsingular spectrum analysis and support vector regressionrdquoApplied Mathematics and Computation vol 320 pp 444ndash4512018

[7] P Singh and B Borah ldquoForecasting stock index price based onM-factors fuzzy time series and particle swarm optimizationrdquoInternational Journal of Approximate Reasoning vol 55 no 3pp 812ndash833 2014

[8] S Lahmiri andM Boukadoum ldquoIntelligent Ensemble Forecast-ing System of StockMarket Fluctuations Based on Symetric andAsymetric Wavelet Functionsrdquo Fluctuation and Noise Lettersvol 14 no 4 2015

[9] S R Das D Mishra and M Rout ldquoA hybridized ELMusing self-adaptive multi-population-based Jaya algorithm forcurrency exchange prediction an empirical assessmentrdquoNeuralComputing and Applications pp 1ndash24 2018

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 12: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

12 Mathematical Problems in Engineering

[10] L A Laboissiere R A S Fernandes andGG Lage ldquoMaximumand minimum stock price forecasting of Brazilian power distri-bution companies based on artificial neural networksrdquo AppliedSo Computing vol 35 pp 66ndash74 2015

[11] L Lei ldquoWavelet Neural Network Prediction Method of StockPrice Trend Based on Rough Set Attribute Reductionrdquo AppliedSo Computing vol 62 pp 923ndash932 2018

[12] S Lahmiri ldquoIntraday stock price forecasting based on varia-tional mode decompositionrdquo Journal of Computational Sciencevol 12 pp 23ndash27 2016

[13] S Lahmiri ldquoATechnical Analysis Information FusionApproachfor Stock Price Analysis and Modelingrdquo Fluctuation and NoiseLetters vol 17 no 01 p 1850007 2018

[14] J-ZWang J-JWang Z-G Zhang and S-P Guo ldquoForecastingstock indices with back propagation neural networkrdquo ExpertSystems with Applications vol 38 no 11 pp 14346ndash14355 2011

[15] Y Shynkevich T M McGinnity S A Coleman A Belatrecheand Y Li ldquoForecasting pricemovements using technical indica-tors Investigating the impact of varying input window lengthrdquoNeurocomputing vol 264 pp 71ndash88 2017

[16] I Svalina V Galzina R Lujic and G Simunovic ldquoAn adaptivenetwork-based fuzzy inference system (ANFIS) for the fore-casting the case of close price indicesrdquo Expert Systems withApplications vol 40 no 15 pp 6055ndash6063 2013

[17] X Zhou Z PanGHu S Tang andCZhao ldquoStockMarket Pre-diction on High-Frequency Data Using Generative AdversarialNetsrdquo Mathematical Problems in Engineering vol 2018 ArticleID 4907423 11 pages 2018

[18] Z Wang J Hu and Y Wu ldquoA Bimodel Algorithm with Data-Divider to Predict Stock Indexrdquo Mathematical Problems inEngineering vol 2018 Article ID 3967525 14 pages 2018

[19] S Lahmiri ldquoInterest rate next-day variation prediction basedon hybrid feedforward neural network particle swarm opti-mization andmultiresolution techniquesrdquoPhysica A StatisticalMechanics and its Applications vol 444 pp 388ndash396 2016

[20] L Tao Y Hao H Yijie and S Chunfeng ldquoK-Line PatternsrsquoPredictive Power Analysis Using the Methods of SimilarityMatch and Clusteringrdquo Mathematical Problems in Engineeringvol 2017 Article ID 3096917 11 pages 2017

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom

Page 13: Predicting Stock Price Trend Using MACD Optimized by ...MACD histogram 1 Buy 381 275 280 285 290 295 300 305 date 22 24 26 28 Candlestick chart 275 280 285 290 295 300 305 date −2

Hindawiwwwhindawicom Volume 2018

MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Mathematical Problems in Engineering

Applied MathematicsJournal of

Hindawiwwwhindawicom Volume 2018

Probability and StatisticsHindawiwwwhindawicom Volume 2018

Journal of

Hindawiwwwhindawicom Volume 2018

Mathematical PhysicsAdvances in

Complex AnalysisJournal of

Hindawiwwwhindawicom Volume 2018

OptimizationJournal of

Hindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom Volume 2018

Engineering Mathematics

International Journal of

Hindawiwwwhindawicom Volume 2018

Operations ResearchAdvances in

Journal of

Hindawiwwwhindawicom Volume 2018

Function SpacesAbstract and Applied AnalysisHindawiwwwhindawicom Volume 2018

International Journal of Mathematics and Mathematical Sciences

Hindawiwwwhindawicom Volume 2018

Hindawi Publishing Corporation httpwwwhindawicom Volume 2013Hindawiwwwhindawicom

The Scientific World Journal

Volume 2018

Hindawiwwwhindawicom Volume 2018Volume 2018

Numerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisNumerical AnalysisAdvances inAdvances in Discrete Dynamics in

Nature and SocietyHindawiwwwhindawicom Volume 2018

Hindawiwwwhindawicom

Dierential EquationsInternational Journal of

Volume 2018

Hindawiwwwhindawicom Volume 2018

Decision SciencesAdvances in

Hindawiwwwhindawicom Volume 2018

AnalysisInternational Journal of

Hindawiwwwhindawicom Volume 2018

Stochastic AnalysisInternational Journal of

Submit your manuscripts atwwwhindawicom