With development of the society and improvement of economy, more and more people began to contact the stock and become shareholders. However, the stock market is like a sea, and blind purchase or following may bring economic losses. On the contrary, if reliable technical strategies are used for transactions, additional benefits may also be generated . Therefore, it is necessary to understand some technical trading rules in the stock market.
There are many technical trading rules for studying stocks, such as MACD, KDJ, MA, etc., of which MA (Moving Average) is widely used. However, sometimes one indicator may not be able to directly determine the trend of stock price changes. For example, BBI (Bull And Bear) has only one average line, no comparison object, and cannot directly observe the price changes. Therefore, a better result can be obtained by combining with other indicators. For example, by combining BBI with MACD, we can find stocks in multi dominant and medium-term upward trend . Wang  translated 12 trading strategies into price dynamic equation by using the fuzzy system in his article, including moving average rule, support and resistance rule, trend line rule, etc. These models were compared with random walk model; And through the simulation, it illustrates how the simple technical trading rules generate complex price changes. From the article, we can see that there is no significant difference between the individual moving average rule model and the random walk model in the price curve generated, but when other models such as the support and resistance rule are added to the price dynamic equation, the price curve has changed a lot. This further illustrates that sometimes using two trading strategies at the same time can better capture the price trend. In this paper, we use Wang’s method to combine MA and BBI, and study the trend changes of the stock price under these two trading strategies by transforming the technical trading rules into a mathematical function.
2. Moving Average Rule
Let N-day moving average of stock price be
is defined as the relative change of M-day and N-day price moving average.
Next, we define the membership function. Firstly, we divide the range of relative change of stock price moving average into seven fuzzy sets: Positive Small, Positive Medium, Positive Large, Around Zero, Negative Small, Negative Medium, Negative Large. The membership functions corresponding to them are shown in Figure 1, and each fuzzy set can be represented by a piece-wise function. For example, the membership function of the fuzzy set NM is
where w is a positive constant to describe the small or large. In this paper, we take , which means that the difference between M-day moving average price and N-day moving average price is about 1%.
In order to transform technical trading rules into mathematical functions, we first transform technical trading rules into If-Then rules in fuzzy system theory, and then combine If-Then rules into fuzzy system, namely excess demand function. First, let be the trading strength of a group of traders, then we can get the price dynamic model:
Figure 1. Membership functions of fuzzy sets (above) and trading signal (below).
where means there are groups of traders who trade from t to , and the same group of traders use the same trading technical.
Let ed be the trading intensity, which is used to represent excess demand. Then the buying and selling signal corresponding to the change of stock price is represented by fuzzy sets, which can also be divided into seven fuzzy sets: Buy Small, Buy Medium, Buy Big, Neutral, Sell Small, Sell Medium and Sell Big. The membership functions corresponding to them are shown in Figure 1, and each fuzzy set can also be represented by a piece-wise function. For example, the membership function of the fuzzy set SM is
Next, we transform the moving average rules into seven fuzzy If-Then rules in fuzzy system theory.
If is Positive Small, Then is Buy Small;
If is Positive Medium, Then is Buy Big;
If is Positive Large, Then is Sell Medium;
If is Negative Small, Then is Sell Small;
If is Negative Medium, Then is Sell Big;
If is Negative Large, Then is Buy Medium;
If is Around Zero, Then is Neutral.
The fuzzy rules used here are a corresponding formal transformation based on their corresponding rule definitions and fuzzy system theory. From the above seven rules, we can conclude that the excess demand function of the moving average rules is
where , , , , , , , and , , , , , , are the centers of the fuzzy sets , respectively.
Substitute (6) for (4) to get
Equation (7) shows that traders use the moving average strategy to observe the change of stock prices. Let simulate equation (7), as shown in Figure 2.
The first 100 stock prices are generated by random walk model
where is a Gaussian random variable with a mean value of 0 and a variance of 1, and we take ; we take the random walk model as a contrast. The last 400 stock prices are generated by (7). From Figure 2, we can see that there is no big difference between the stock price curve generated by moving average rule and random walk model. In the next section, we will add the BBI to observe the stock prices trend changes.
3. Bull and Bear Rule
BBI is a common indicator to judge whether the stock is in a Bull or Bear state. Before converting the BBI index into the If-Then rule in the theory of fuzzy system, we first define the formula for calculating the Bull and Bear index. Here we understand that for the average value, the longer the period, the greater the change in the mean value, then for the original definition of BBI taking the average of different periods, the impact of the long period on the overall will be relatively large, so we adjust the weight of different periods in this paper. We give the maximum weight of 3 days average value of 0.4, and the weight of 6 days, 12 days and 24 days average value decreases by 0.1 in turn. It can be expressed by formula
Figure 2. Three times dynamic simulation of stock price generated by random walk (0 - 100) and moving average (100 - 500).
If we record , , then (9) becomes
The basic idea of BBI is that when the price breaks the short lines, it indicates that the situation of Bear positions or Bull positions is changing, and the trading decision can be made at this time. Specifically, we can write the following heuristics:
A sell signal is generated if the stock price in the high price area with the closing price breaking through the BBI lines from the top to bottom;
A buy signal is generated if the stock price in the low price area with the closing price breaking through the BBI lines from the bottom up to.
Next, we translate the BBI heuristics into the If-Then rule in the theory of the fuzzy system. Before that, we first define the relative changes of the current price and the BBI line as follows:
Now we transform the BBI heuristics into the If-Then rules in the theory of the fuzzy system:
If is Negative Small, Then is Sell Small;
If is Negative Medium, Then is Sell Medium;
If is Negative Large, Then is Sell Big;
If is Positive Small, Then is Buy Small;
If is Positive Medium, Then is Buy Medium;
If is Positive Large, Then is Buy Big.
The combination of these rules into a fuzzy system is as follows:
Figure 3. Three times stock price dynamic simulation generated by random walk (0 - 100) and model (12) (100 - 500).
where , , , , , , , , , , , are the centers of the fuzzy sets , respectively.
Substituting (6) and (11) into (4) gives
Formula (13) indicates that 2 groups of traders conduct a transaction at the same time, with one group using the moving average strategy and the other group using the BBI strategy. We simulated (13) three times with , , , , , as shown in Figure 3, in which the first 100 pt were still generated by the random walk model (8) and the last 400 pt were generated by the model (13).
From Figure 3, we can see that compared with the first 100 pt curves generated by the random walk model, the pt curves generated by the latter 400 moving average rules and BBI rules at the same time fluctuate more sharply, which indicates that after we add BBI indicators into the dynamic equation, the stock price shows more trends. Therefore, we can see that the combination of the two indices can better observe the trend of stock prices.
People who understand the stock know that the stock price is not all spontaneous, but can be controlled by people, mainly determined by the behavior of stock traders. And with the in-depth understanding of the stock, we can understand the importance of technical trading. Although it is a fuzzy system, it is also a fuzzy set divided according to the actual problems, and the last step in the whole process is accurate calculation. Therefore, as long as the division is reasonable and in line with the reality, the final calculation result of the fuzzy system is accurate enough. At the same time, the speed is also considerable. The model of hundreds of data takes only a few seconds . As for the stability and robustness of fuzzy control, firstly, fuzzy control has strong stability and robustness, because it is constructed by people’s experience and knowledge, and has certain reliability in application. Secondly, for the fuzzy system, we only input the required variables without redundant interference, which makes the system relatively simple and has no other complex programs, so it can run stably .
In this paper, the stock technical trading strategy is combined with the theory of fuzzy system, which is further transformed into a specific mathematical language to study the dynamic changes of the stock prices, and explains how the rules of technical trading affect the prices. From Figure 2 and Figure 3, we can see that when the BBI is added to the dynamic equation, the price will change significantly, that is, when the moving average strategy and the BBI strategy are combined to observe the stock price, we are more likely to capture the price changes. Therefore, we conclude that sometimes it is clearer and easier to capture the trend by combining the two indices to observe the changes in the stock prices. In the future, we can convert more technical trading rules into dynamic price equation, and combine more indicators to better observe the trend of changes in the stock market.
 Wang, L. (2015) Dynamical Models of Stock Prices Based on Technical Trading Rules— Part III: Application to Hong Kong Stocks. IEEE Transactions on Fuzzy Systems, 23, 1680-1697.