https://www.mql5.com/ru/articles/1350

article has been prepared based on the results of theoretical and practical research company to Heaven, Stairway and contains the intact part of the accompanying documentation to the analytical range of The Wild Cat’s Strategics® for MetaTrader 4. Company Stairway to Heaven is a copyright holder on The Wild Cat’s Strategics® for MetaTrader 4, registered in the Russian Federal service for intellectual property, patents and trademarks. The author of the article is the developer of the complex and has the right to this publication. The code that accompanies this article is based on some previously published scripts and indicators, the authors have made to the code in the fields of copywriters.

### introduction

this paper briefly let the general problem, put the task and consistently solve it, revealing the underlying concepts and principles form the basis for a new look at financial markets, technical analysis, the very paradigm trading.

since the decision allows alternative implementation of the part of the tasks that are already protected, one of the goals of this article is to attract the attention of developers to research and seek other solutions might better and/or more interesting.

Traders is available ready-to-use technical analysis and forecasting tool. This tool is the next stage of development was published in 2007 year indicator Extended Regression StopAndReverse, credited with the recognition of many users. However, the code can be used by developers as the final module of data reporting in their own implementations of solutions.

1. Review of the general concept of infrastructure

**1.1. Put the task in General …**

attempts to the mathematical description of the markets, as well as various internal and external dependencies research courses financial instruments devoted to already enough serious work.

the overall effect of them is disappointing conclusion-markets possess magnificent self-protection from determination and have pronounced the “seep” through various research-oriented models, which are designed to ensure necessary for practical trading stability prediction accuracy for a period of time required by the overwhelming mass of traders.

in this regard, we can recall the words of George Soros, good suitable as a summary to this state of affairs:

… they can’t get perfect knowledge about the market because their thinking is itself constantly affect the market, and the market affects their thinking.

whether here, that create a fully deterministic mathematical models of market impossible? Generally speaking, in the framework of practical trading look for the answer to this question is meaningless, because aspects of trading are in the field of art, rather than science. However, science has great potential to help the entire process of trading.

there are some scientific methods and approaches that can be successfully applied in the work on the financial markets. Here, emphasis should be placed on the approach to such application. What is important for a trader? Now casually would mention the so-called “black boxes” mechanical trading systems. You can speak as about the benefits and harms of MTS, but only the final output, which is important, and it is also disappointing.

Since most traders simply become hostages of the MTS-specific principles, quality design and errors of these programmes, which cannot be avoided, trading turns from art in broken mechanism, defects which are hidden and unpredictable.

in addition, traders should clearly know and understand when and on what sites you can use rate of price change specific MTS, and when not to. And the condition is too often not executed, and the apparent ease of use MTS otuchaet traders from the need analysis. In this regard, we will talk not about MTS.

so, among other things, the trader is important enough accurate prediction on which he could rely on, and according to which it would be possible to dynamically generate and adjust their action in the market. In turn, forecasts can be divided into two groups-predictions in the form of various predictions, based on some scientific methods, and forecasts through direct transfer interpolated data.

to make it clearer, as examples of such predictions can remember build two curves on the charts, sometimes very similar externally. The first was built by Singular Spectrum Analysis “, in Russia known as” Caterpillar “, and the second is a simple moving average with shift. Of course, it’s not the best examples, but now it is not important. We shall not here considered flaws and merits of both methods, it is only important that they both apply the various traders in its work with varying degrees of success.

essentially, both of these methods differ only by the fact that SSA is trying to predict the changing some parameters in the future and calculating and displaying moving average does not predict anything, this method only displays a visual indication of the converted the most basic way to real data. Strictly speaking, in the latter case, the prediction itself no, Outlook makes the trader himself, based on the position of the course relative to the moving average, which is a tool for the prediction. In both cases, the trader is conducting some analysis.

Thus, trading on scientific projections intended to facilitate the work of the markets, but at the same time such trading more risky, because the errors are corrected by a trader forecasts late, often not valid.

on the other hand, trading on the direct transfer of data eliminates errors of mathematical calculations/predictions, but increases the intellectual load on the trader. If we now consider the average differences in psychology and mentality of many traders, in General, based on the results of trading, it turns out that in practice there is no much difference between the two groups shall have the predictions.

a significant difference becomes manifest when the technique of scientific forecasts begin to complicate himself too much, thereby increasing the likelihood of errors, their quantity and quality. It would seem that here we have a contradiction between the initial conditions and the end result.

in fact, if you decide to use scientific methods to obtain predictions, and while simple ways to solve this problem do not give acceptable results on factor accuracy. How to avoid increase of errors in their methods, and whether you can generally avoid them in quantity when the forecast is already losing the desired accuracy? The question is ambiguous and can easily lead to logical impasse or call attempts to solve in the forehead by the long trains of various simple methods and their combinations.

where and how to look for a happy medium between the source and the degree of difficulty, calculation methods and accuracy of the final results? Perhaps there is a whole lot of decisions. At least one such decision and involved.

**1.2. We divide it into parts.
**

since we are talking about technical trading, initial data limited history in quotations, i.e. we have a total of four bars and bar prices, values without volume. The volume values should be ignored because these values from source to source varies over a wide range and the true volume of trades do not meet. In this regard, it makes no sense to use them in calculations because the same price data we will get different predictions, which in itself is contrary to the task.

on the other hand, price changes course investigated financial instrument already contain information about the real, true, since trading volume directly depend on them. We will process the available series and provide the processed data to a Visual display in the chart.

in order not to complicate the solution, the entire task split into these two parts-the processing of data by using a scientific method and final processing and displays on the screen. The decision to begin with the end.

**1.3. Define tasks for the second half of the solution. **

assume that we already have preprocessed data projection which must be placed on the schedule. What to do this, select a method, an approach, a way to represent data, so that it made the lowest distortion in the finished material, and at the same time would be a potential prediction analysis views?

the mathematical apparatus has a sufficient arsenal of elegant solutions, among which we can highlight and select regression analysis as a method that satisfies the criteria specified above already.

regression analysis is a statistical method research of dependencies, and with some point of view it can be considered as a simple way to present the data without any distortion in the source material. One of the goals of regression analysis is to predict values of a dependent variable. For the task at hand this method fits almost perfectly.

can I take it that it is the second part of the problem solved? Yet. The decision marked only as a whole, it is necessary to determine the type of regression. Let’s see what we will have in the case of linear regression.

suppose pretreatment data indicated the starting point of the building is one of the local extremums EURUSD rate in late autumn 2007. Build from that point channel of standard deviations, which represents the central beam of linear regression.

Figure 1. Channel standard deviations from the regression line, built for EURUSD

the value of the peninsula received the forecast?

rules channel trading tactics are well known. Obviously, the value of this forecast will vary greatly from trader to trader, however, we know that such predictions are quite acceptable and widely used.

is also well known and shortcomings of this kind of predictions. This we now know that the EURUSD punched the top border of the Canal and continued its ascent, and at that time, traders were faced with the choice of action, conjugated and risk, and with the heat of emotion.

here’s a natural question arises: whether one of the purposes of the regression analysis related to predicting values, better use in projections in order to facilitate the decision-making process of selecting some critical moments? Yes, you can. This requires a data view based on **polynomial regression**where the extrapolated series will be the desired Outlook, predicting, kind of a hint.

Output on the graph of the same point in the same channel of standard deviations, but based on the Central curve as interpolated and jekstrapolirovannogo numeric number of polynomial regression.

Figure 2. Channel standard deviations polynomial regression line, built for EURUSD

Good prognosis. Just what you’re looking for a more confident and calm work. It is only necessary to emphasize that in the case of an error with the parameters of this method of prediction will turn into its opposite. Of course, such a mistake would not mistake the method itself, it will be the developer’s error.

the perfect method within the framework of the task at hand, and now you can take it that its the second part resolved, since we decided on the method of data presentation.

in fact, it’s hard to imagine something more familiar and friendly than aiming channel with levels of standard deviations, vector which moves rates. Compared with different linear channels, in this case, we have a more accurate forecast, and trading tactics is nothing new, it is well understood and clear even intuitively.

Here you can recall about another aspect of the analysis. How to relieve a trader taking decisions on entering the market, closing and/or spread their positions? Factor of trading signals in the form of a “black box” makes the same risks and negative consequences of that and the MTS. Use additional oscillators-select individual, and what is important here is that the trader knew, understood what exactly he shows a particular indicator, otherwise it also becomes hostage to the program.

That can offer in this regard mathematics in help a trader? On the one hand, the polynomial regression data extrapolated in themselves are warning forecast, which should be used to identify areas of input/output. On the other hand, in the general practice of trading adopted de facto standard levels of “Stop Loss” as the delimiter, losses when the inevitable errors in the operation of the markets.

Implement dynamic levels displayed on the chart “Stop Loss” does not carry any special work, this algorithm is simple and well known. It is only necessary to determine the recalculation method levels, and here yourself perfectly proved the concept of standard deviation. Calculation of the deviation of the course on the range from the start point to the already known zero bar is not complicated.

as a result, we have directly on the chart with all the necessary information for technical analysis, which you can get at this stage. Calculated levels look like “Stop Loss” in polynomial channel of standard deviations:

Figure 3. The calculated levels of “Stop Loss” in polynomial channel of standard deviations

and, accordingly, the warning “a polynomial time forecast” in Visual perception:

Figure 4. EURUSD rate flow forecast when the polynomial regression

this decision final submission data as in MQL4 code attached to the article.

Module is ready and can be used as a technical tool. However, all his hidden potential and prospects in the field of forecasting will fully in a single integrated several components that will be shown below.

the following material may provide guidance in finding alternative solutions for the pretreatment of the data.

**1.4. Define the solution for the first half. **

it should be noted that the sampled information submission option reduces the balance of tasks in General, to the definition of the starting point, point of reference, that is another advantage of ultimate handling.

in fact, the method of regression analysis saves us from different kinds of difficult physical and mathematical synthesis in the early stages, we do not need to display the price in the range of rate changes and attract fetched superposition of harmonic constituents and other methods that lead to fluctuations and distortions end of data relative to the original numeric row as foundations most probabilistic prediction located closest to reality.

Although the starting point, you can use any method, just as a pointer to it. However, this solution to preprocessing are also charged with pretty stringent requirements, since the entire method in General, called the wave method of regression implies deep loops and negative and positive feedback between their mathematical components.

evaluation of the long-term work of various researchers of market patterns and natural wave processes, as well as own results previously calculated mathematically and empirically obtained subsequently, leads to conclusion about the existence of at least one theory to an acceptable degree of accuracy dynamically describe the structure of the market, and based on this structure by using regression analysis to predict future price changes.

it’s about Elliott wave theory, defining the so-called law of waves. Modern development of this theory led to the birth of several independent directions, among which stands out the fractal wave branch as the most promising for their respective developments. This direction and was selected as a working hypothesis for the entire wave method of regression.

**1.5. Assemble all the components together**

so, in the final version of the solutions we have implemented project mathematical methodology definition and description of fractal-wave structure of the numeric series, written by market quotations, plus analysis method the resulting description of the structure and prediction of fluctuations of financial instruments studied.

in doing so, we need not a starting point, and the entire fractal structure, because structure defines the parameters of polynomial regression and State reporting fractal parameter trend/correction.

in addition, a description of the structure allows you to use additional graphs linear tools like Fibonacci levels and Pitchfork Alana Andrew:

Figure 5. Additional tools (Fibonacci levels and Andrew fork) for the analysis of fractal structure

1.6. Fractal-wave matrix

modern fractal wave theory laid the groundwork for targeted studies of various phenomena, including both physical and economic.

the results of these studies were presented in the proper form of mathematical data, ready-made data considered in the applied aspect in relation to the real market, and then categorized appropriately. For all the identified group sustainable Fractals created unified matrix adapted to use as input data for the calculation of polynomial regression.

as is well known, the fractal is a stable structure, scalable and repeatable in any of these scales. In fact, this should mean that the same fractal type will have enough similar form and on the monthly timeframe, and the tick chart. **However, in a real market, the internal structure of Fractals is susceptible to destruction and distortions. This happens more often than smaller timeframe under consideration.**

fractal Structure consists of other Fractals like or not like to external form. The younger the timeframe, the more intensely on it manifested a chaotic price movements, which are commonly referred to as market noise. When the level of noise exceeds some threshold value destruction occurs a fractal structure.

fractal Shape is distorted so much that he falls out of a multitude of specific sustainable Fractals. At the same time frames, the threshold for noise level increases and the fractal structure becomes much more stable.

from the above you can make important interim conclusion that it is necessary to comprehend and keep attention and analysis-even in the case of breakdown and destruction of fractal structure in small timeframes still rate will continue its movement the senior generation of fractals. This conclusion is important for trading any urgency because potential orientation in the film market.

**1.7. The concept of market cash flows**

for practical trading makes no sense considering the preconditions for the emergence of a stable low level of fractals in the market-they are completely transparent and does not affect the quality of work and the amount of profit.

on the top, custom level, it is advisable to consider and determine important primitive Fractals, influencing the fluctuation in the near future and RRientirujushhie trader in the current situation.

it will be later shown in the examples, but first you must submit Fractals in a form that would be clear, natural and familiar to every trader, regardless of its level of knowledge and training. Here there is a direct analogy with the rivers and their tributaries, sources and other natural characteristics.

on every timeframe developing fractal structure forms stable for some period of time equilibrium flows of money supply. Imagine a pool with filling and discharge pipes. Through the first tube pool constantly filled, through second-water constantly flows. Obviously, the incoming water volume should be the same as the outgoing volume to ensure a constant level of fullness of the pool.

Market flows are formed around, if the total amount of incoming and decreasing the money supply in a dynamically changing range of bars reporting timeframe. Here is valid and the inertia of Newton, as repeatedly convinced every trader on a thin market, where the aggregate money supply is not great, the course fairly easy moves small means, nested in the market.

flows produce large Like a lot, but not each of them should be considered separately. Practice and common sense say that the optimal number of threads allocated is three for each timeframe.

one must represent the main stream, the river flowing on the timeframe. The other two are sleeves of this river, or internal threads or additional filling and idler pipes-as easier to understand. Wave regression channels makes sense interpreted as Bank the main river and its branches, or, respectively, as conditional thread boundaries or as a shell pipes.

completes the whole concept of the postulate of the existence of the global, or in other words the basic flow is the main financial instrument for the River as a whole. This is the thread that is composed of the totality of the entire money supply, present on the market and related to a particular financial instrument. This thread is obviously is the inertial, and all the traffic course, all development of a variety of fractal structures within the shores of basic River.

Thus, the concept of cash flows largely removes the uncertainty in price movements, and together with tv wave hands gives the regression traders further direction in the topology, as well as market analysis and forecasting.

### 2. Elementary Fractals as a driving force of the market

**2.1. Fractals-primitives**

primitive Fractal is a billet for trends and corrections. It is formed by three consecutive extremum in the graph, and therefore such a fractal can be defined as the minimal (primitive) steady recurring structure.

Primitives is laced with any and every timeframe, and it is from the primitive folds the multiplicity structure fractal wave matrix. You can specify only four such primitive, others simply does not exist.

as an example, all four primitives, following each other on the same thread. Three dots (a-b-c) formed the template for the upward trend. This Fractal has only three defining characteristics:

- extremum point in the above point of extremum and.
- extremum point in the above point of extremum with.
- extremum point from above the point of extremum and.

Figure 6. Harvesting the upward trend

the emergence of such a basic structure in any timeframe from M1 to MN1 clearly precedes the upward trend in the same thread in which formed the fractal-primitive. However, until price fluctuations do not rise above the point and remain abroad formed a primitive, the upward trend will remain in unacknowledged, unstable condition. In this case we see formed confirmed uptrend.

rule: one thread per confirmed a rising trend should the downward correction.

the rule asserted about the absence of any alternatives-if in the stream formed the uptrend, and this trend is confirmed, after graduation in the same thread can arise only downward adjustments, without exception.

it follows that any uptrend after its confirmation, generates the following preparation, basic structure of fractal-primitive preceding the downward correction. This Fractal also has only three defining characteristics:

- extremum point in is located below the point of extremum and.
- extremum point in is below the point of extremum with.
- extremum point from above the point of extremum and.

it should be borne in mind that, after the confirmed trend should always be adjustments, but adjustments should not necessarily be only after confirmed the trend, there are other options.

Nevertheless, the emergence of such a basic structure in any timeframe clearly precedes the downward correction in the same thread in which formed the fractal-primitive. Illustration: in this case

Figure 7. The downward correction of

the following three extremum points formed the template for upward adjustment. As we can see, in this case, the adjustment was not following the trend, and after adjustment. This fractal, like the two previous considered primitive also has only three defining characteristics:

- extremum point in the above point of extremum and.
- extremum point in the above point of extremum with.
- extremum point from below the point of extremum and.

this basic structure in any timeframe clearly precedes upward correction in the same thread in which formed the fractal-primitive. Illustration: in this case

Figure 8. A bearish correction

it is easy to see that the upward adjustment considered formed a fourth type of elementary Fractals-preparation for the downward trend, mirroring the already described earlier the fractal the previous upward trend. Denote the three defining characteristics of the fourth primitive:

- extremum point in is located below the point of extremum and.
- extremum point in is below the point of extremum with.
- extremum point from below the point of extremum and.

the emergence of such a basic structure in any timeframe from M1 to MN1 clearly precedes the downtrend in the same thread in which formed the fractal-primitive.

Similarly, as in the case of extraction for the upward trend, but in inverted form, until price fluctuations do not fall below the point in and would be the boundary formed by primitive downtrend will remain in unacknowledged State. Also, there is a similar rule.

rule: one thread per confirmed downward trend should be upward correction.

rule also argues the absence of any alternatives-if in the stream formed the downward trend, and the trend is confirmed, after graduation in the same thread can arise only ascendant adjustment without exceptions.

it follows that any downward trend after its confirmation, generates the following preparation, basic structure of the primitive preceding the fractal upward correction. How long would not have continued the downward trend, it will sooner or later be followed by upward adjustment.

Describes the workpiece prior upward correction has already been given above.

Visual form the fourth basic fractal-the illustration below.

Figure 9. Downtrend

For any trend should always be oppositely directed correction. For correction may follow as the trend and following the adjustment, but in any case this movement will be opposite in the preceding adjustment.

**2.2. The driving force of the market**

one way or another, but entered the market and the output of it money violates the dynamic equilibrium flows. Arriving water makes flowing river to the “North Pole” up by price axis. Waning Gibbous-the “South Pole” down on this axis.

despite the existence of universals “trend” and “correction”, courses for financial instruments are always able to trend in a thread that is the main driver of the market in any given period delta changes prices.

rule: the main driving force in any market is a trend.

of its structure and the level of its development trends can be simple, elongated and truncated. If the trend could not display the price beyond the primitive fractal, and it remains unconfirmed to counter the trend movement, this trend falls into the category of truncated. Truncated trends typically occur within corrections, as well as in the structures that form the basis for the following trends.

Wave patterns in the law Elliott wave also have sample truncated trends. This pattern is called “Truncated5” and is a pared down fifth impulse wave, which does not go beyond the level of an extremum of the third impulse wave.

in General, each confirmed the trend is either a simple or extended. Elongated trends in near the low thread have confirmed the trend and price beyond 100% from the base, bringing it up to 162% and beyond.

examples of such patterns in the context of the Elliott wave theory-“Extension1” as elongated first wave, “Extension3” as long the third wave, “Extension5” as long the fifth wave pulse. Simple trend may be composed of its structure as a trend, and correction, but usually simple trends limited to the level of 100% of the district’s founding. Wave patterns-for instance “Impulse”, “Impulse2”, or more complex examples-“Diagonal1”, “ExpTriangle5”.

rule: adjustment must have trend for at least one level of iterations of its structure.

Correction often have intricate shapes and heterogeneous structure. Wave theory defines a large number of corrective patterns, but in General, in terms of primitives will be useful to all the corrective movement regarded only as simple and complex.

simple Structure adjustment consists of a superior by the number of episodes of apparent trends. The structure of the elaborate correction-from a series of explicit adjustments are also superior in number. However, in any case, each correctional movement has deep in its structure, the driving force behind the trend. This driving force is often displays corrective formations beyond the 100% recovery.

here is a basic example of a fractal-entity represents a classic truncated trend originating mostly older, “Long” thread. The resulting fractal (a-b-c) identified a downtrend. This trend, according to their evolving capacity, undertook drastic oscillatory movements off course from the standard Fibonacci levels.

regression model showed the main thread of the depletion of the trend after another rebound prices from the level of 61.8% Fibonacci extensions. Depletion occurred in the unacknowledged State trend-dot “in” not broken down.

in such a disposition is seen explicit preparation for a counter-trend movement-primitive, consisting of the points “b”, “c”, and the point of rebound rate from the level of 61.8%. Thus, truncated trend formed a foundation platform for the subsequent uptrend under the older flow.

Figure 10. Basis of the upward trend

uptrend in “Long” thread was implemented as an elongated, its structure consisted of a series of sequential trends in two junior River flows constantly adds to the enjoyment of its waters by two tributaries.

Previously, during the rebound rate from the level of 61.8% Fibonacci extensions, this pair of sleeves provided the required outflow of money supply, causing and was fully formed and implemented a consistent pattern of “truncated trend-long trend of two primitive Fractals.

at the same time, the longer trend was the main driving force for the development of the first phase of the correction movement in high fractal structure, which was followed by the second phase adjustment, total completed the formation of a new Fractal-like primitive basis for global trend 2006-2008 Gg. A detailed analysis of the EURUSD rate using the implemented software system, you can take on the company’s website Stairway to Heaven.

Conclusion

so again were showing features of MetaTrader 4 in the implementation of research-oriented projects. In general terms, presented the idea of fractal wave matrix and the new concept of market flows in the form of nonlinear wave channels regression.

the article as a whole is aimed at attracting the attention of developers affected aspects and nuances of technical analysis and prediction, since the potential in this area is far from being exhausted. In turn, the company Stairway to Heaven expresses its appreciation and thanks to the developers of MetaTrader 4.