The stock market plays an increasingly important role in the global economy. Accurate stock price forecasting not only aids government in predicting economic trends, but also helps investors anticipate higher expected returns. Nevertheless, hurdles such as non-linearity, complexity and high volatility make it a daunting task to predict stock prices. To address this issue, this paper proposes a new hybrid model, termed Hierarchical Decomposition based Forecasting Model (HDFM), to decompose and forecast stock prices in a hierarchical fashion. The model utilises complete ensemble empirical mode decomposition with adaptive noise (CEEMDAN) for the initial decomposition of stock price time series. To enhance the predictive efficiency, sub-series with similar sample entropy from the decomposition are combined with the K-means clustering method. Through thorough analysis, it is found that the first combined sub-series contains more high-frequency signals. Therefore, the first combined sub-series is subjected to a second decomposition with variational mode decomposition (VMD). Afterwards, the gated recurrent unit (GRU) model is used to predict each of the sub-series individually. The final results are obtained by merging the prediction outcomes. The proposed model has been evaluated on three different stock markets. The experimental results showed that the proposed model outperformed other forecasting methods across all the stock indices. Moreover, ablation studies demonstrated the effectiveness of each individual component within the proposed model.