Research Article

Predicting Stock Price Trend Using MACD Optimized by Historical Volatility

Algorithm 1

General algorithm for HVIX and EMA-HVIX.
Require: Set up parameters
 The stock closing price is , the historical volatility index is , the length of the closing
stock price data is , the weight of is , the weight of is ,
and the time parameters are and .
for j=1 to () do
    sum=0;
    for i=j to (j+) do
     Generate return series
     
     Sum the return in the past days
     sum=sum+
    Calculate the mean return in the past    days
    R_mean=
    sum=0
    for i=j to (j+) do
      
      Sum the variance in the past days
      sum=sum+;
    Calculate the standard deviation in the past    days
    
for j=1 to () do
    sum1=0
    for i=j to (j+) do
     sum1=sum1+;
    sum2=0;
    for i=j to (j+) do
     sum2=sum2+;
    Calculate  
    
for i=2 to () do
    
Calculate    and  
Calculate  
for i=2 to length()  do
    
Calculate