# Mathematical modeling of the probability of trend continuation

*Master Class: Through the Eyes of Science*

*Trend or time series trend** - is a somewhat conventional notion. A trend is understood as a regular, non-random component of a time series (usually monotonic), which can be calculated according to a well-defined unambiguous rule. Trend Analysis and Determination of Trend Duration
is one of the main moments in trader's work. Therefore, mathematical modeling of the probability of existence and monotonicity of a trend, as well as the estimation of its probable duration is a relevant task [1,3].*

The trend of a time series is often related to the action of physical laws or some other objective laws. However, it is impossible to unambiguously divide a random process or time series into **regular part (trend)** и **oscillatory part (residue)**. Therefore, it is usually assumed that a trend is some function of a simple form (linear, quadratic, etc.) describing the "behavior as a whole" of a series or process. If isolation of such a trend simplifies the study, the assumption of the chosen form of the trend is considered acceptable.

Fig. 1. The trend of the weekly chart dollar/.ruble.

Once you have a linear trend, you need to find out how significant it is. This is done by using **ratio analysis correlations**. The point is that the difference of the correlation coefficient from zero and thus the presence of the real trend (positive or negative) can turn out to be random, related to the specifics of the considered interval of the time series. In other words, when analyzing another set of experimental data (for the same time series) it may turn out that the obtained estimate is much closer to zero than the initial one (and, possibly, even has a different sign), and it becomes difficult to talk about a real trend here.

To check the significance of a trend, special methods have been developed in mathematical statistics. One of them is based on checking with **Student's distribution**.

Fig. 2. Trend in the weekly euro/dollar chart.

In addition to the linear trend, we have to consider trends of a more complex structure. In this case, it is usually not possible to specify in advance the function with which this trend can be described. That is why in practice we often just go through several simple functional dependences (with parameters) and for each of them estimate how successfully a function of this or that type can describe the trend of the time series in question. If a computer is available, these calculations do not take much time, and sometimes they can even be carried out in automatic mode, selecting among several given types of trends the optimal one. However, by no means always there is a function among the considered functions which describes the trend of the given time series efficiently enough. In this case it is necessary to follow other ways. In particular, in this situation various transformations of time series members are performed (logarithm, differentiation - formation of differences of neighboring members of a series, integration - summation of consecutive members of a series, etc.) in order to try to obtain a time series with a clearly expressed linear trend. If it can be done, the methods described above are applied to the obtained series, and then the inverse transformation is applied back to the original series. It should be emphasized once again that **the type of trend is not uniquely defined by the series itself and is some conditional object**The process of the process under consideration is more fully understood.

Hard ** Model and automate the evaluation of trend detection** in the time series. However,

**if the trend is monotonic**(steadily increasing or steadily decreasing), it is usually possible to analyze such a series. If a time series contains a significant error, the first step of trend extraction is smoothing. It always includes some way of local averaging of the data, in which the nonsystematic components cancel each other out. The most common method of smoothing is a moving average

*,*in which each term of the series is replaced by a simple or weighted average

*n*neighboring members, where

*n*- the width of the sample. Instead of the mean, you can use the median of the values in the sample. The main advantage

**median smoothing**The main advantage of median smoothing, compared to moving average smoothing, is that the results become more robust to outliers (those present within the sample). Thus, if there are outliers in the data (associated with measurement errors, for example), then median smoothing usually results in smoother, or at least more "robust", curves than a moving average from the same sample. The main drawback of median smoothing is that, in the absence of outliers, it leads to more "jagged" curves (than moving average smoothing) and does not allow the use of weights.

Relatively less often, when the measurement error is very large, is used **least squares smoothing**, weighted with respect to distance,* *or **negative exponentially weighted smoothing method**. All of these methods filter out noise and transform the data into a relatively smooth curve. Rows with relatively few observations and a systematic arrangement of points can be smoothed using splines. However,** **many monotone time series can be well approximated by a linear function. If, however, there is a clear monotonic nonlinear component, the data must first be transformed to remove the nonlinearity. Usually a logarithmic, exponential, or (less often) polynomial transformation of the data is used for this purpose.

The general superficial familiarity with the subject of economic theory breeds contempt for special knowledge about it - a judgment of Nobel laureate M. Friedman [2]. * *From a practical point of view, whenever a future course of events (a chain of troubles or successes, a deteriorating or improving trend, etc.) is predicted based on the expectation of a continuation of something previous, it is essentially, in one form or another, a bet on **law of inertia**. Not surprisingly, it has long been detected in the movement of stock prices. Here any development of events can be represented as an arbitrary combination of two states - rest inertia or* *inertia of motion, which once emerged under the influence of a certain impulse of any nature: macroeconomics, psychology, the will of chance, etc., and now, having come out of the period of rest, continues. In the sixties of the XX century appeared a number of scientific papers, which gave a mathematical justification for the existence of the trend, with the breadth of the term "inertia of the economy", understood in the sense of the impossibility for the entire mechanism of economic management sharply turn to another course. Having analyzed the model of behavior of market participants the conclusion can be made that the market cannot change its moods from bullish to bearish and vice versa at once, from where such a notion as "**market inertia**". The sheer mass of the market does not allow them to maneuver quickly, and any maneuvers must be initiated well in advance, or they simply will not work at FOREX market. Continuously performing "turns", **the market can move anywhere, but this movement can be predicted** due to the "inertia of the market. Where exactly the market is going at the moment can be quite difficult to predict. The task becomes easier if we assume that there is a trend in the market. Then it is possible to understand with a certain accuracy where the currency rate is likely to be at the next moment. A sharp maneuver is possible in this case, but it requires a lot of strength. This can also explain the inertia inherent in the FOREX market.

### FOREX SSA prediction method

One of the powerful methods of time series analysis is a method called SSA - **Singular Spectrum Analysis**. This method is used to analyze and forecast time series as a filter. Let us briefly describe the principle of this method.

For the analysis of the time series we select the parameter ** L - let's call it "window length". **Parameter

*L*can be chosen arbitrarily. If the row length is large enough and the value is large enough

*L*the results will not depend on the window length [4, 5]. The SSA-Caterpillar method can solve various problems, such as,

**trend highlighting**, periodic detection, series smoothing, and construction of the complete series decomposition into the sum of trend, periodic, and noise. The fee for such a wide range of possibilities with rather weak assumptions is, first, the essentially non-automatic grouping of the components of the singular expansion of the trajectory matrix of the series in order to obtain the components of the original series. Secondly, the absence of a model does not allow to test the hypotheses about the presence of this or that component in the series (this drawback is objectively inherent to all nonparametric methods). For instance, the research of a currency pair by linear methods has revealed the presence of non-stationarity in the behavior of a time series, which leads to the conclusion that it is impossible to build a high-quality forecasting model on the basis of parametric methods. An attempt to build a forecasting model based on a nonparametric approach ("Caterpillar" -SSA) yielded more encouraging results.

**The time series obtained on the basis of the built model correctly indicated the main direction of series movement. At the same time, the built model could not predict the fluctuations of the series within the main trend. In order to improve the quality of the forecast, an attempt was made to move away from the theoretical recommendations for creating a model and to try to set parameters based on intuitive considerations. However, this**

**the result did not lead to the desired one. As a result, it was concluded that the model built in accordance with the theoretical recommendations and the corresponding limit of prediction accuracy was optimal.**

Therefore, the representation of a trend of a fundamental indicator in the form of a symbolic chain of fuzzy variables is a new element that simplifies the formal description of characteristic features of a trend and their further processing. For example, using the structural methods of pattern recognition, which have proved successful in automatic pattern recognition in technical diagnostics for solving the task of assessing the interaction of macroeconomic dynamics processes and exchange rates, associated with a set of* *of the fundamental indicators of FI(*x _{i}*),

*x*∈X. Obtaining such estimates makes it possible to identify for subsequent analysis in the examined set of causal relationships only those relations of fundamental indicators FI(

_{i}*x*),

_{i}

*x*∈X, where there is a real influence of one fundamental indicator on the trend of the other, which leads to a compression of the conceptual scheme of the macrosystem in question.

_{i}At the same time, taking into account the fact that market participants widely use the evaluation of the similarity between the trends of the given indicators [6, 7] in order to evaluate the influence of one fundamental indicator on the trend of another one, it is reasonable to use the pattern recognition theory applied in the quantitative form of the fundamental indicators trends to get it. **procedure for calculating the Euclidean distance between these trends.**

If the qualitative form of setting trends of fundamental indicators in the form of a symbolic chain of fuzzy variables to solve this problem should be used **methods of linguistic and syntactic analysis of experimental curves**. The essence of this type of analysis is that for the investigated type of experimental curves a dictionary of symbols, setting possible states of trends, and a grammar, allowing constructing from the dictionary symbols constructions - descriptions of experimental curves, are created. The construction of symbolic trend chains of fundamental indicators with the use of one or another formal grammar makes it possible to offer to recognize the influence of one fundamental indicator on the trend of another fundamental indicator by performing the procedure of evaluation of similarity of grammatical parsing trees. This approach is quite simple, new and well formalizable. Here, it should be taken into account that similarity and difference measures of the structure of complex systems are constructed according to special rules.

### Literature

1. Sobolev V.V.. Currency Dealing in Financial Markets / Yu. - Novocherkassk, 2009. - 442 с.

2. Kahnke V.A. Philosophy of Economic Science. INFRA-M, 2009. - 384 с.

Bezruchko B.P., Smirnov D.A. Mathematical modeling and chaotic time series. Saratov: State Scientific Center "College", 2005. 320 с.

4. Golyandina N. E., Method "Caterpillar"-SSA: Analysis of Time Series; Tutorial. - SPb. 2004. - 76 с.

5. Golyandina N. E., Method "Caterpillar"-SSA: Time Series Forecasting; Tutorial. - SPb. 2004. - 52 с.

6. Murphy J. The Visual Investor. How to Identify Trends.-M.:Diagram,2004. - 326 с.

7. Murphy John J. Intermarket Technical Analysis. Trading Strategies for Global Markets for Stocks, Bonds, Commodities and Currencies. - Moscow: Diagram, 1999. - 317 с.