# Important Trading Point Prediction Using a Hybrid Convolutional Recurrent Neural Network
## 4 Deep Learning Framework for Important Trading Point Prediction
### Problem Statement  
First, we need to define the IPs with a formula so that we can label the historical data before these points in the training sets. Then, we can employ the proposed HCRNN to learn the internal laws of such important trading points from the labeled historical data on the training sets. As described in Section 3.1, breakout points are important trading points. A breakout occurs when a stock price moves outside a price barrier. To describe  
Figure 3: Four examples of bullish candlestick patterns.  
such a situation quantitatively, we simplify it as a situation in which the stock price is significantly higher than the average price of the previous period; i.e., it is significantly beyond the fluctuation range of the previous period. Considering a time series of trading prices \(\{p_{t}\mid t=1,2,\ldots,T\}\) of a stock, inspired by the focus on high-margin opportunities principle and the definition of trading breakout [54; 55], we define the important trading points as follows:  
\[\text{if}\;(p_{t}/\text{ average}\;(p_{t-1},p_{t-2},\ldots,p_{t-L})\geq W): \tag{1}\] \[p_{t-1}\text{ is an IP}\]  
where the hyperparameter \(W\) denotes the threshold beyond which the stock price is considered to show a significant rise. \(L\) is another hyperparameter that specifies the length of the previous period. Conceptually, the model's performance is influenced by these two hyperparameters. In the experiments, this research represents an attempt to find the best values of these hyperparameters to achieve good performance in the developed framework. However, (1) cannot ensure that the stock price breakout takes place on date \(t\) rather than on date \(t-1\); e.g., suppose that \([p_{t-2},p_{t-3},\ldots p_{t-L}]\) are very low, but \(p_{t-1}\) is very high, and \(p_{t}\) is slightly lower than \(p_{t-1}\). In this situation, \(\text{average}\;(p_{t-1},p_{t-2},p_{t-3},\ldots,p_{t-L})\) is relatively low and (1) is satisfied, but in fact, the stock price breakout takes place on date \(t-1\) rather than date \(t\). To avoid this situation, we add the condition that \(p_{t}\) increases monotonically, and (1) is revised as follows:  
\[\text{if}\;(p_{t}/\text{ average}\;(p_{t-1},p_{t-2},\ldots,p_{t-L})\geq W\quad \&\quad p_{t}>p_{t-1}): \tag{2}\] \[p_{t-1}\text{ is an IP}\]  
Based on the keep track for some time principle, broadly analyzing a sequence of historical data and combining them into a unified context is helpful for obtaining a more reliable prediction; thus, we regard the sequence of recent historical data before an IP as the signal of an important trading point (SIP), denoted as \([p_{t-1},p_{t-2},p_{t-3},\ldots p_{t-L}]\), where \(L\) is the length of the SIP. Then, we can label SIPs in training sets by the following rule:  
\[y=\left\{\begin{array}{ll}1,&\text{ if }x\in SIP\\ 0,&\text{ if }x\
otin SIP\end{array}\right. \tag{3}\]  
where \(x\) denotes the time point in input sequences, and \(y\) is a binary class that indicates whether the time point \(x\) belongs to a SIP; the category \"1\" indicates belonging to a SIP, and the category \"0\" indicates not belonging to a SIP. Therefore, the important trading point prediction problem can be formulated as follows: given the historical time series of a stock \(\{x_{t}\mid t=1,2,\ldots,T\}\), the goal of this task is to classify each time point into one of two categories, belonging to a SIP (\"1\") and not belonging to a SIP (\"0\"), according to the past stock data. If the model output is consecutive \"1\" values with a length of \(L\), these time points constitute a SIP, and the last time point of the detected SIP is an IP. Note that there are only one compare operation and \(L\) assignment operations at each time point during the labeling process. The time complexity of this label algorithm is \(\text{O}(n)\), thus, the labeling process is very fast, and the algorithm could be used to handle a large amount of data. Next, we propose a hybrid neural network to learn the function\(f(x)\) to predict the class of each time point.