A Study on Stock Graph Recognition Based on Wavelet Denoising and DTW Algorithm

. The “classical pattern” of stock price formation has long been widely used in the determination of future price trends of stocks, and the identiﬁcation and analysis of classical price patterns have an important guiding role in investors’ decision-making and trading. The wavelet transform is a useful tool to remove some of the noise of time series because it has the characteristic of multiresolution. In this study, we propose a method for stock price pattern recognition based on the wavelet transform and dynamic time warp (DTW). A pattern recognition method with similar quantiﬁed results is developed to obtain accurate pattern recognition results. That is, using the wavelet transform to smooth the original price graph, and then using the DTW algorithm improved in this study to ﬁnd the graph with the smallest distance from the target graph under the sliding window method, the identiﬁcation and analysis of the target graph can be realized. In order to improve the recognition rate of the target graph, we preprocessed the raw price sequence using the moving average convergence and divergence (MACD) algorithm based on the control experiments set up in this study. The pattern recognition method used in this study will identify the price patterns of a certain time window as a whole, thus avoiding the problem of how to objectively select the important points that constitute a price pattern and the mathematical deﬁnition of diﬀerent price patterns in the previous traditional methods.


Introduction
Technical analysis based on trading pattern curves is an important method for quantitative analysis of stocks, and in recent years, there have been a number of scholars who have proved the effectiveness of technical analysis from different perspectives as an effective means of extracting information from market prices [1][2][3].With the development of financial engineering, computer technology, and mathematical algorithms, technical analysts using traditional trading model analysis methods now regularly use statistical software packages and other data processing techniques.e use of data analytics can minimize or even completely eliminate human subjective influences and turn trading into a scientific practice.erefore, it is important to find a method that can quickly and efficiently identify trading pattern curves automatically to help investors grasp the volatility patterns of the stock market.
Existing stock pattern recognition methods can be divided into rule-based pattern recognition and templatebased pattern recognition, both of these methods are based on the extraction of important points and are subjective in nature.
erefore, this study attempts to use the overall graphical identification, that is, the overall identification of the price pattern of a certain time window the abovementioned approach can avoid the problem of how to objectively select the important points that constitute the price pattern and the mathematical definition of different price patterns.Based on this, this study selects an arbitrary time window from the A-share market as the target graph, which avoids mathematical definition of price patterns and increases the universality of the method.e appropriate wavelet parameters are then selected by empirical analysis and the original price series is smoothed using the wavelet transform.An improved DTW algorithm is used to accurately identify the target pattern by finding the stock among the remaining stocks that is most similar to the target pattern.Scholars also recently used machine learning or other intelligent algorithms for financial time series graph identification, but the basic approach is consistent with the abovementioned two categories [4][5][6].
e main tasks of this study include the following: (1) the entropy weighting method is used to determine the weights of the two indicators of information extraction rate and information extraction error, and then to determine the composite indicators according to their weights, and finally to determine the number of optimal decomposition layers of the wavelet and the selection of the wavelet threshold function based on the value of the composite indicators.(2) e DTW algorithm is improved to overcome the problem that the algorithm itself is far away from similar shapes with certain phase differences.is study uses an improved DTW algorithm with a sliding time window algorithm to find the most similar time window to the target graph.(3) Attempt to compare the average rise and fall of the target graph to its similar graph sixty days later and determine that it is a realistic guide.
e overall structure of this article is as follows.Section 1 is an introduction that reviews the background of graphic recognition technology and the main work of this study.Section 2 presents work on graph recognition.Section 3 briefly introduces wavelet denoising and the theoretical foundations of MACD metrics and explains the principles of the wavelet threshold function.Section 4 describes technological improvements related to the characteristics of financial time series.Section 5 empirically determines the number of layers of the wavelet optimal decomposition as well as the threshold function and the graphs most similar to the target graphs found by the abovementioned methods.Section 6 compares the optimal graph with the forty-day rise and fall of the target graph.Finally, we conclude this study in Section 7. e specific research ideas are shown in Figure 1.

Related Work
e current research on automatic price pattern recognition has fallen into two main categories as rule-based pattern recognition and template-based pattern recognition.
Lo et al. [7] were the first to mathematically define ten price patterns such as head-and-shoulders and doublebottoms using the partial pole method.He proposed a systematic, automated method for technical pattern identification using nonparametric kernel regression and applies the method to a large number of U.S. stocks from 1962 to 1996 to evaluate its effectiveness for technical analysis.e abovementioned method creatively realizes the automatic recognition of price patterns by computer.Suh et al. [8] defined a Bezier curve as consisting of seven significant points and then identifies the pattern of the "cup with handle" by calculating the correlation coefficient between the time window and the Bezier curve.Savin et al. [9] used the pattern recognition algorithm of Andrew W with some modifications to determine whether "head-and-shoulders" (HS) price patterns have predictive power for future stock returns.Zapranis and Tsinaslanidis [10] represented the ideal circular base as an isosceles triangle formed by three key points and then used the two congruent circles on the outer ring of this triangle to control price fluctuations.e final two-dimensional coordinates of price and time were used for automatic pattern recognition.
Template-based pattern recognition is the network lattice method represented by Leigh et al. [11].Leigh represented the flag as a weight-based grid and used it as a template to compare it with a time series window and determined whether the sequence matches the template based on the price percentile and a genetic algorithm.Wang and Chan [12] used the flag template method, which represents the top and bottom of the dome as a network lattice based on price fluctuations, as a template for identifying and examining buy signals.Royo et al. [13] defined flags from a new perspective and modified the grid weights.
Directly using an existing stock pattern curve as a template before using either of these methods will likely lead to overfitting and will be inefficient, also the accuracy and reliability of the analysis will be compromised [14,15].erefore, when studying complex time series, scholars will first perform some preprocessing on the raw data.In order to improve the mining efficiency, scholars have proposed an approximate representation of the time series, which is a compressed representation of the time series, by retaining the main information of the time series and ignoring the tiny details. e current time series approximation methods have included discrete Fourier transform [16], discrete wavelet transform [17], piecewise aggregate approximation [18], symbolic aggregate approximation [19], and singular value decomposition [20].Pattern recognition belongs to a type of time series mining.In conjunction with the above overview of price pattern recognition, time preprocessing before pattern recognition can be broadly divided into two categories.(1) Nonlinear curve description.Commonly used methods are nonparametric kernel regression methods and Gaussian kernel estimation methods.Dong used a Gaussian kernel estimation method to smooth the estimation process on the raw data [21].(2) Approximate representation based on segmentation.For example, Keogh et al. [22] proposed a bottom-up approach for segmenting time series and extracting their features.Gong reduced the complexity of time series using perceived important points proposed by Chung [23,24].
Wavelet transform has been an important way to preprocess time series, especially for nonstationary, nonlinear, and heteroskedastic signals [25].erefore, many scholars have used wavelet transforms to preprocess the raw data before building stock prediction models.
e abovementioned prediction models show that the prediction accuracy of the original data is greatly improved after wavelet transform processing.In addition to neural network algorithms, there are other algorithms such as SVMs that are combined with wavelet transforms.e experimental results also showed that the hybrid model incorporating the wavelet transform is better than the prediction using a single algorithm [29][30][31][32].DTW is a kind of elastic measurement for calculating time series similarity [33][34][35].As DTW can extract morphological features of time series and handle time transformations and distortions, it can be used for pattern representation of stock time series.For example, Han developed a portfolio optimization model 2 Mathematical Problems in Engineering with strict constraints to obtain a pattern representation of stock time series based on DTW [35].
According to the abovementioned research, at present for the price pattern automatic identification has achieved some results, there is still room for improvement: (1) in the study of automatic price pattern recognition, the time series preprocessing method is relatively homogeneous.Due to the needs of pattern recognition, the automatic identification of price patterns uses a single method.(2) e extraction of important points in the perception of important points method is highly subjective.(3) In identifying patterns, most studies have used the sliding window method, which allows for the existence of other points between the extreme points of the pattern, but does not consider the relationship between the extreme points of the pattern and other points, which is prone to misjudgment.For this reason, the study will combine the advantages of DTW and wavelet transform to establish a time series expression based on holistic graphs.

Theoretical Foundation
3.1.Wavelet Denoising Principle.Set a noise-containing sequence F(t), which can be represented by the following model: In the above equation, s(t) is the true sequence and e(t) is the white noise.

Mathematical Problems in Engineering
Suppose that the noise e(t) is white noise with zero mean and variance σ 2 .Set the wavelet function to φ a , W e a, t to be the wavelet transform of e(t), which is obtained from the continuous wavelet transform theory. (2) It is known from the hypothesis that Substituting the formula in (2) into (3) gives the following reasoning: e purpose of sequence f(t) denoising is to suppress the noisy part of the sequence e(t) to obtain the true sequence s(t); it follows from the abovementioned reasoning that the noise wavelet transformed w e (a, t) is inversely proportional to the scale a. erefore, it is possible to denoise the sequence using the different characteristics exhibited at each scale after the noise and sequence wavelet transform.

Wavelet Denoising Principle.
e method was proposed by Donoho and Johnstone [36].e basic principle is that the orthogonal wavelet decomposition has the ability of time-frequency local decomposition.When performing sequence processing, the wavelet component exhibits a large amplitude, in contrast to the uniform variation of the noise in the high-frequency part.e larger amplitude wavelet coefficients are overwhelmingly useful sequences; the smaller amplitude coefficients are generally noise after wavelet decomposition.at is, it can be assumed that the wavelet transformation coefficient of the useful sequence is greater than the wavelet transformation coefficient of the noise.en, a suitable threshold is selected according to certain rules, wavelet coefficients greater than the threshold are retained while wavelet coefficients smaller than the threshold are processed accordingly, and finally the useful sequence is reduced according to the processed wavelet coefficients.e key to the threshold denoising method is to pick an appropriate threshold value.According to the relationship between wavelet coefficients and the threshold, the threshold function can be divided into hard threshold denoising, soft threshold denoising, and zero-threshold denoising method.In addition, there are other threshold denoising methods, such as suppressing detail denoising (suppressing certain layers to obtain detail coefficients based on actual denoising requirements).ese four threshold denoising methods are compared in detail in the experimental section of this study.
Suppose that the time series equation is as follows: e result of doing the wavelet transform on both sides of the above equation simultaneously is as follows: e wavelet transform of the actual sequence is equal to the sum of multiple wavelet transforms.
e orthogonal wavelet transform of the original time series is able to remove the f(t) correlation to the greatest extent possible, retaining a few and relatively large amplitudes on the wavelet coefficients to a large extent, while the noise e(t) will be distributed across all time axes at all scales with relatively small amplitude after wavelet transformations.According to the abovementioned principle, the wavelet coefficients of the noise are minimized at each scale of the wavelet transform, and then the processed wavelet coefficients are used for sequence reconstruction to suppress the noise.e specific steps of the abovementioned method are shown in Figure 2.

MACD Fundamentals.
In order to get better experimental results, this study uses the MACD algorithm to process the raw data to form a new MACD curve and then uses the DTW algorithm to compare the distance between the MACD curves.
e MACD algorithm is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price.is preprocessing method can be used to eliminate price disturbances and enhance the trend of the original price graphs, ultimately resulting in a better fit.e mathematical principle of the MACD algorithm is as follows: EMA(t) is a moving average of t days, EMA(t − 1) is yesterday's moving average, n is the period, and price is the original price series.t-day maps t different weights.From the above equation, the weights increase over time, so EMA(t) is a better reflection of the future trend of the price chart line.DIF (the difference between the short-term average price of a stock and its long-term average price) is defined as follows: EMA(t 1 ) is a fast-moving average and EMA(t 2 ) is a slow-moving average; the difference between the two can reflect the future upward or downward trend of the price chart line.DEA (difference exponential average) is defined as follows: A weighted average was applied to the abovementioned DIFs, with the same weight settings as EMA.In the above equation, DEA ′ is the previous period DEA.HIST (histogram) is defined as follows: From the above formula, the HIST can better reflect the rise and fall of the original price series and eliminate the influence of price on the DTW algorithm.In this study, the closing price of 000009.szfrom January 1, 2019, to July 24,4 Mathematical Problems in Engineering 2020, is selected and the relevant graph line is plotted as shown in Figure 3.It is obvious from the abovementioned chart, the original price sequence chart line (signal line in the chart) increase is basically consistent with the MACD column in the chart, so the MACD column line can reflect the increase of the original chart line.In addition to the above advantages, MACD removes price distractions when fitting graphs.
erefore, this study converts the standard graph line to an MACD line as shown in Figure 4.

e Process of Rolling Window with DTW.
e article selected the raw price series with m data points as the target graphic.e remaining stock price series with n data points is then divided chronologically into subsegments with m data points.A total of (n/m) subsequence fragments can be obtained, and the subsequence fragments are labeled using Window(i).e window(i) with the smallest distance from the target graph is obtained using the DTW algorithm.e rolling window process with DTW is shown in Figure 5.

Financial Time Series Wavelet Denoising Analysis and DTW Improvements
e time series can be smoothed using the abovementioned theory, but there is still the problem of parameter determination.According to the flow of financial time series processing by Lan and Ma [37], there are three important parameters that affect the final denoising effect: the choice of the wavelet base function, the number of decomposition layers, and the choice of the threshold function.

Characteristics of Financial Time
Series.Stock price data, which is typical of financial data, commonly includes stock trading data and yield data calculated from trading data.However, both types of data exhibit an unsteady nature and the data are more volatile.In particular, financial time series are densely populated with singularities, so it is generally difficult to smooth out the financial time series.In addition to large fluctuations, there are small fluctuations in the data, which are highly stochastic and spread throughout the time window.Generally, large fluctuations contain more useful information and are therefore generally retained as useful information; a large number of small fluctuations are generally chosen to be removed due to their randomness and lack of value for analysis and prediction.

Selection of the Wavelet Function.
At present, wavelet functions are more diverse and have different properties, which are suitable for different scenarios.e purpose of this study is to identify the graph of a stock in a given time window.Different wavelet functions have different denoising effects, so it is important to choose the right wavelet function.e following analysis of wavelet function characteristics is closely related to denoising.
Because there is often a correlation between wavelet function properties (it has been shown that there is no symmetric tightly-branched orthogonal wavelet base, except for the Harr wavelet), it is impossible to find a wavelet function that has all the optimal properties.e purpose of this study is to smooth the financial time series and different wavelet functions correspond to different denoising effects; it is crucial to choose the appropriate wavelet function.e Mathematical Problems in Engineering following analysis focuses on a number of features that are closely related to the noise removal effect.
(1) Orthogonality: the wavelet function with orthogonality can maintain the noncorrelation between the wavelet coefficients to improve the denoising performance of the wavelet function.More importantly, orthogonality is necessary to achieve fast wavelet transforms, and thus orthogonality is necessary to achieve wavelet denoising.
(2) Compact support: it means that the wavelet function is nonzero in the effective interval, so the smaller the support width of the wavelet or scale function, the better the local resolution of the wavelet and the finer the denoising effect.(3) Vanishing moment: since there are a certain number of singularities in the financial time series, it is necessary to apply a certain vanishing moment so that as many wavelet coefficients as possible are zero or generate as few nonzero wavelet coefficients as possible to increase the denoising effect.e larger the vanishing moment, the more wavelet coefficients are zero, so there is a positive correlation between the vanishing moment and the width of the support.at is why there is a compromise between the vanishing moment and the width of the support.e vanishing moment is proportional to the number of singularities present in the sequence, while the stock price sequence has more singularities, so the vanishing moment can be increased accordingly.(4) Symmetry: the wavelet function with symmetry will reduce the error after wavelet transformation, so this property is conducive to the recovery and reconstruction of the sequence after noise removal.However, this property has less influence on the noise removal effect than other properties.is study finds a number of commonly used wavelet functions to examine, the properties of which are shown in Table 1.
For the aforementioned wavelet function, SymN is the best choice for the following reasons: (1) it is orthogonal, enabling wavelet denoising.(2) ere are more "spikes" in the stock price sequence, so it is necessary to ensure that the wavelet has a vanishing moment.SymN is the best choice because of the compromise between the vanishing moment and the width of the support.(3) SymN has better symmetry than DbN as well as Conif, which can reduce errors during sequence reconstruction.

Determination of the Number of Decomposition Layers
4.3.1.Wavelet Noise Reduction Evaluation Index.Since wavelet denoising is mostly used inside engineering, the requirements for denoising in engineering are different from the requirements for denoising in finance.In order to measure the effect of sequence denoising, the article defines two variables, information extraction rate (IER) and information extraction error (IEE), drawing on the wavelet threshold method selected by Liu [38] to measure the effect of sequence denoising, considering f as the original time series,  f as the denoised time series, and IEE and IER defined as follows: From the above equation, the information extraction rate is positively related to the similarity of the denoised sequence to the original sequence.e larger the information extraction error, the smoother the denoised sequence is compared to the original sequence.
e abovementioned two indicators are negatively correlated, and if the information extraction rate is combined with the information extraction error to form a composite evaluation indicator, the process of increasing the number of decomposition layers will inevitably result in a maximum value.e graphical interpretation of this maximum value is the optimal ratio of the sequence in retaining detail information to its approximation information, which corresponds to the number of decomposition layers.e above demonstrates the feasibility of using a combination of information extraction rates and information extraction errors to form new composite evaluation indicators through theoretical analysis and also based on the numerical characteristics of the indicator changes.

Establishment of Composite Evaluation Indicators.
Different evaluation indicators have different scales and units, and in order to eliminate the incommensurability this brings, the study treats each evaluation indicator as nonquantitative.In order to preserve the difference between the information extraction rate and the information extraction error, this study chooses to use the averaging method in the no-quantization method.If there are m indicators in the composite evaluation, each with n units, the indicators are x ij (i � 1, 2, ..., n; j � 1, 2, ..., m), which represents the jth indicator value of the i-th unit, and y ij represents the jth index value of the i-th unit after dimensionless homogenization.e formula is as follows: e mean value of each indicator after the mean method is 1 and its variance is as follows: e variance of each indicator after averaging is the square of the coefficient of variation x j of each indicator, which retains information on the degree of variation of each indicator.After averaging, the indicators become the same order of magnitude, and if they are to be combined linearly, weights need to be assigned to each indicator.Since the averaging method preserves the variability among the indicators, then weighting requires the elimination of the variability among the indicators, for which entropy weighting is chosen in this study.Entropy is an ideal metric for multiobjective decision-making and evaluation.It relies on the amount of decision-making information to improve the accuracy of decision-making, so it can objectively reflect the implicit information of the indicator data, improve the resolution of the indicators, avoid the selection bias caused by small differences in indicators, and reflect a full range of indicator information.
ere is an inverse relationship Mathematical Problems in Engineering between the entropy of an indicator and its weight.
According to the concept of entropy, entropy Q is defined as follows: In the above equation, H j is defined as follows: In the above equation, f ij is defined as follows: e above equation satisfies  n j�1 Q j � 1. e use of entropy weighting allows for the combination of multiple metrics to determine weights, both to account for associations between multiple samples and to weaken the effect of outliers.
e choice of entropy weighting and a measureless mean, i.e., a combination of differential and nondifferential, would theoretically be a good one.
According to the abovementioned method, wavelet decomposition is first performed on the original time series to calculate the IER j and IEE j for different decomposition scales J. en, the dimensionless averaging process is performed to get the  IER j and  IEE j .Finally, the information extraction rate weights Q IER and the information extraction error weights Q IEE are calculated from the entropy weights.
en, the formula for the value of composite indicator S is as follows:

DTW Algorithm Improvement.
e main objective of the study is to fit the graphs formed by stock prices in a particular time window, and the degree of similarity of the fit is achieved by the DTW algorithm.In order to improve the fit to the target graph, this study makes improvements to the traditional DTW algorithm.e article randomly constructs three sequences of length 20, where s2 is derived from s1 translation and s3 has no relationship with either of the above.e three sequences are shown in Figure 6. e distance between s1 and s2 is 5 and the distance between s1 and s3 is 4.12, calculated using the traditional DTW algorithm.us, it can be seen that the traditional DTW algorithm is not very effective for the distance of the postshift sequence.is study proposes an improved DTW algorithm.
(1) Determine the largest common substring of the two sequences seq1 and seq2, the length of which is given by a.
(2) seq1 and seq2 are numerical sequences that set a maximum standard deviation of the offset tolerance in finding the longest public sequence.In other words, two values within this standard deviation are considered to be part of the public sequence as well.(3) Define the attenuation factor α as follows: e length of the common subsequence of both sequences is negatively correlated with its attenuation coefficient, thus enabling improvement of the algorithm.e distance between s1 and s2 is 0.982 and the distance between s1 and s3 is 2.512, as recalculated by the improved algorithm.It follows that the improved DTW algorithm effectively reduces the distance between the periodic sequences after translation.

Methodology.
is study arbitrarily selects five stocks in the A-share market as the target graphics and determines the wavelet denoising parameters by the abovementioned entropy weighting method.An improved DTW algorithm is then used to find other stock time windows from the stock market that are the least distant from it.In order to achieve better experimental results, this study introduces MACD algorithm to convert the original price series into "MACD graph line" on the basis of wavelet denoising.
en, the distance between the calculated original price series is transformed into the distance between "MACD lines," which improves the accuracy of the result.

Source of Experimental Data.
All stock data in this study are from the Tushare website (https://tushare.pro)and include trading date, opening price, high price, low price, closing price before compounding, and uncompounded upside and downside.Stock data are daily data and the time frame studied is from the listing of each stock to July 24, 2020.

Stock Price Sequence Wavelet Denoising Process. (1)
Choose the appropriate wavelet base function and decomposition layer N for the time series f.
(2) reshold quantification of the decomposed highfrequency coefficients is performed, and for each layer from 1 to N, the appropriate threshold and the appropriate threshold function are selected to obtain the estimated wavelet coefficients.(3) e original time series is reconstructed (performing wavelet inversion) based on the low-frequency coefficients (scale coefficients) of the Nth layer after wavelet decomposition and the high-frequency coefficients (wavelet coefficients) of each layer after threshold quantization.e wavelet reconstruction is then performed using the reconstruction algorithm to obtain the denoised postdecomposition sequence.
Because the daily stock closing price sequence is essentially a one-dimensional discrete sequence, this focuses on the wavelet decomposition of the onedimensional discrete sequence.Experiments show that when a white noise sequence is wavelet decomposed, it can be found that the decay rate of the high-frequency coefficient after wavelet decomposition is proportional to the number of layers of wavelet decomposition, and the variance of the same coefficient is inversely proportional to the number of layers of wavelet decomposition.us, for the general case, there is a positive relationship between the number of decomposed layers and the smoothness of the denoised sequence.erefore, in this study, we have to find the most suitable wavelet denoising parameters based on the characteristics of the stock price sequence.

Wavelet Denoising Parameter Investigation.
is study selects five stocks in the China A-share market (ticker symbols: 300327.SZ, 300332.SZ, 300336.SZ, 601567.SH, and 601616.SH) as target patterns I-V, respectively.e results of denoising the abovementioned five target graphics using hard threshold, soft threshold, zero threshold, and inhibited detail factor threshold functions combined with the wavelet decomposition layer number method are shown in Tables 2-5.
From Table 5, it can be seen that the integrated index score of wavelet decomposition layers and threshold function shows a trend of increasing and then decreasing, and when the number of wavelet decomposition layers is 4 and the suppression detail factor threshold method is selected, the integrated evaluation index value is the largest, and this experimental result is consistent with the results of the previous mathematical derivation.e data of the abovementioned five stocks are obtained by random sampling, but they all show the maximum value on the same parameters as above, which fully demonstrates the generalizability of the method.
e abovementioned five graphics are compared with the original graphics after the abovementioned wavelet denoising method which is shown in Figure 7.

Finding Time Windows Similar to the Target Graph Using the DTW Algorithm.
is study selects five stocks in the China A-share market (ticker symbols: 300327.SZ, 300332.SZ, 300336.SZ, 601567.SH, and 601616.SH) as target patterns I-V, respectively.e optimal DTW distances and similarities found using the abovementioned methods, respectively, are shown in Table 6.
e time complexity of all the abovementioned algorithms is O(n 2 ).
e above results show that there is a significant improvement in the final similarity of the original data smoothed using wavelet denoising compared to using the original data directly (the average similarity of the five graphs of the three methods is 0.3612, 0.5075, and 0.8936).
is result verifies the need for wavelet denoising.
e final similarity of using MACD data compared to direct use of raw data is also significantly improved.erefore, the final graph recognition method used in this study is to first transform the original data into MACD graphs, then use wavelet denoising to smooth the MACD graphs, and finally use the improved DTW algorithm to achieve effective recognition of the target graphs.
e most similar graphs of the five abovementioned SDs after wavelet preprocessing and direct search using the DTW algorithm are shown in Figure 8.
e most similar graphs found using the DTW algorithm after the abovementioned five target graphs were processed by MACD and then denoised using wavelets, as shown in Figure 9.

Empirical Analysis of China's A-Share Market
In order to find out the pattern of the stock market in the short-term and to compare the effectiveness of the abovementioned two methods, the article calculates the average upside and downside of the current time window of the underlying graph and the average upside and downside of the 40-day time window of the optimal graph after the two treatments.e forty-day average increase and decrease in the underlying and optimal graphs are shown in Table 7: As can be seen from Table 7, the average rise and fall of the optimal graph obtained using the MACD preprocessing method compared to the direct use of the raw data is closer to the average rise and fall of the base graph over the next forty days.is result confirms the lagging nature of the MACD indicator and the effectiveness of the graphical stock selection, fully demonstrating the practicality of the method in practice.

Conclusions and Discussion
In this study, the wavelet transform is used to denoise the original stock price series, the SymN4 wavelet function is selected according to the characteristics of the stock time Mathematical Problems in Engineering series, and the comprehensive scores of different wavelet decomposition layers and wavelet threshold functions are calculated based on the entropy weight method; the results show that the 4-layer decomposition layers and the suppression detail factor threshold method have the highest scores, so the wavelet denoising parameters finally selected in this study are SymN4 wavelet function, 4-layer decomposition layers, and suppression detail factor threshold method.e improved DTW algorithm was then used to calculate the distance between the two sequences to select the optimal graph that is most similar to the target graph.To overcome the effect of price and other factors on the DTW algorithm, the raw sequence data were standardized using the MACD algorithm and then the optimal graph most similar to the target graph was selected using the DTW algorithm.e comparison experimental results show that the similarity between the final graph and the target graph after the MACD algorithm processing is greater than 85%, which fully demonstrates the effectiveness of the graph recognition method.Finally, by comparing the target graphs with the optimal graphs, it is found that the optimal graphs obtained by MACD preprocessing method are closer to the forty-day average increase/decrease of the underlying graphs (the difference between them is within 0.2), indicating that the method has strong practical guidance significance.e graph recognition methods in this study can be nested in stock analysis software, and stock investors can select existing classical patterns or K-line patterns to find stocks that are similar to them for the purpose of graphical stock selection.is provides a practical technical basis for graphical stock selection techniques.
e graph recognition methods used in this study are all based on a consistent time window size, so it will result in finding the optimal graph with the same time window size as the target graph, and the DTW algorithm can calculate the similarity of graphs with different size time windows, in addition to the overall recognition of the target graph.
erefore, this study does not fully use all the advantages of the DTW algorithm, and in real-life applications, if the problem of matching different size time window graphics can be solved, it will have more far-reaching implications for stock investors.In future work, this study will try to use genetic algorithm to further find the optimal time window size.

Figure 7 :
Figure 7: Comparison of the smoothing process with the original graphics.

Figure 8 :
Figure 8: e graph most similar to the five target graphs.

Figure 9 :
Figure 9: Graphs most similar to the five target MACD graphs.

Table 1 :
Characteristics of different types of wavelet functions.

Table 2 :
Suppression of detail factor.

Table 6 :
Comparison of various methods for optimal DTW distance analysis.

Table 7 :
Comparison of 40-day average upside and downside analysis of various methods.