Our Masha! - page 5

 

Prival писал(а) >>

Even better ) What are these formulas and where do you get them from.

see how the correlation coefficient is calculated https://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D1%8D%D1%84%D1%84%D0%B8%D1%86%D0%B8%D0%B5%

D0%BD%D1%82_%D0%BA%D0%BE%D1%80%D1%80%D0%B5%D0%BB%D1%8F%D1%86%D0%B8%D0%B8

The correlation coefficient is calculated between arrays, not between counts. Please be precise in your wording, so that others may understand what you are saying, what you claim and what you consider.

Sergey, you take and build a correlogram by "your" formula (the one given in wikipedia) and by the one given by me - you will get the same result. The formula I use is simpler and with sufficient sample length the counting error tends to zero, compared to the full form. That's fine with me. If you need more accuracy or mathematical rigour in this matter, please, justify it and use. I in my calculations sometimes (when it is justified) use full expression to construct correlogram:

 
More good and different wands
We don't need an abstract smooth photo model, we are looking for a wand that is not only for the eyes but also has other advantages that are valuable to us.
Machines work differently:
- for a breakdown TS we need a machine stable as a support/resistance line, i.e. smooth enough, integral, lagging, distant from BP.
The number of intersections with the price is critical, because this intersection is a breakthrough = a signal for the TS.
Such MA is lagging by definition.
-For a reversing TS we need a leading and forecasting MA, its position relative to BP doesn't matter.
The number of intersections with the price is not critical as well, because it's the head turn that matters, but not the fixation relative to BP
. In total there are two types, two classes of wands and + lag.
With a zero shift, the same MA is suitable for only one type of TS - a breakout or reversal one, or for nothing at all.
(Non-zero shift MA is a way but presumably only for manual trading)
...
Should the future use of MA be taken into account when designing (finding) it? = two opinions
a) - Generally speaking, it is not necessary to take into account, the main thing is to have))), - get a new MA and try your luck.
b) - After many years of experience with MAs we want something more thorough and less slippery.
...
So with every new Mashka the experienced MTS developer will be more and more cynical,
-more demanding.
However, whether it is possible to synthesise a new MA with preset properties each time is still a big question.
 

Moving on!

So, here is our functional: S=w1*(X[i]-Y[i])^2+w2*(Y[i]-Y[i-1])^2-w3*{(Y[i]-Y[i-1])*(X[i]-X[i-1])}^2-->min minimize it. Let us rewrite it considering the i-th reference to be the current one (the upper equation):

Take the derivative of y[0] from it (second expression) and equating it to zero, solve it with respect to y[0] (third equation), thus obtaining a recurrent expression to calculate the current value of our MA using the known quotient values x[0], x[1] and the previous values of the muv itself y[0] and y[1]. Note that in the expression for the functional, the first two terms responsible for the MA smoothness and its closeness to the quotient coincide with the similar expression for the exponential average. If we follow Bulashov's example described in his article (file located on the previous page) we can exclude one of the adjustable parameters by putting w1+w2=1, then we come to a two-parameter expression for the "ideal" MA:

With w1 being responsible for smoothness and w2 being responsible for proficiency. I guess so.

Now we can do some coding!

 
Neutron писал(а) >> Somebody take a derivative of S by parameter Y[i] and equate it to zero! Because I'm already so-so...

Oh, that's creepy.

S=w1*(X[i]-Y[i])^2+w2*(Y[i]-Y[i-1])^2-w3*{(Y[i]-Y[i-1])*(Х[i]-Х[i-1])}^2-->min

I'm somewhat familiar with the calculus of variations, but only for properly differentiable functions. This is something else. I don't even understand how to solve this problem yet.

 
Neutron >> :

Refresh your memory on the basic requirements for an ideal MA:

1. proximity to the original MA. This requirement is equivalent to the smallness of the distance between quotient X (green line in the figure) and the smoothed curve Y (blue). It can be written that on average, over a large sample, it must satisfy: (X[i]-Y[i])^2-->min

2. Smoothness of MA. This requirement is equal to the smallness of the distance between neighboring samples of the smooth curve: (Y[i]-Y[i-1])^2-->min.

3. The Equity curve that will be composed of the pieces chopped from the initial BP considering the direction (sign) of the opened positions (between vertical lines in the picture) should be increasing. The sign of the position opening is equal to the sign of the MA derivative. In our terminology, sign(Y[i]-Y[i-1]). In this case, the equity curve will be composed of kotier pieces that will be butted together according to the sign of the position to be closed. This is how it can be implemented. Let's construct a first difference series (FFD) d[i]=X[i]-X[i-1] for the kotier. Then the initial BP is easily restored from the FFD according to the algorithm, then a fast growth of the equity curve () is equal to the requirement of maximization of the first derivative from it: dE[i]/dt=E[i]-E[i-1]= sign(Y[i]-Y[i-1])*(X[i]-X[i-1]) or with a small, but admissible, in our case stretch {(Y[i]-Y[i-1])*(X[i]-X[i-1])}^2-->max It is obvious that maximization of some expression, equals its minimization with opposite sign: -{(Y[i]-Y[i-1])*(Х[i]-Х[i-1])}^2-->min.

That's it. We get the required functional for the minimization:

S=w1*(X-Y)^2+w2*(Y[i]-Y[i-1])^2-w3*{(Y[i]-Y[i-1])*(Х[i]-Х[i-1])}^2-->min

We need to find its minimum relative to Y[i], where i is the current datum.

From the mathematical point of view everything is correct.

When I have free time I try to solve something similar, but by another method.

From my point of view (it's not necessarily true, but it may live))) it is not necessary to define function Y and calculate its values. - A neural network can draw this Mashka. A three-layer perceptron with a hyperbolic activation function for each neuron can theoretically cope with the task. The permissible deviation of equity (difference between the quotient and MA, i.e. min) will allow to set the permissible error value for the mesh training. In this case, the value of min should be determined by the acceptable risk level of the TS, but also tends to 0.

In principle, it's simple at first glance, but only at first...

 
Mathemat писал(а) >>

Oh, that's creepy.

Come on, we've already found a solution.

The problem is in the area where the coefficients w1, w2 and w3 are defined. Since in derivation of the functional we did not limit ourselves in any way with respect to their values, it is logical (probably) to put one of them identically equal to 1 (it is w3), and connect the other two as in Bulashov's example. Then we obtain a one-parameter expression for the filter:

Here. Quite simple and tasteful! This is good. Now we can code for sure.

P.S. In general, it would be good if people who know DSP and filter-building basics could help us to define the area of determination of these coefficients (all three). As I remember, you need to find a characteristic equation and satisfy that its roots were inside a unit circle on the complex plane. This will allow you to work with a stable filter and fine-tune all its three knobs. But for now, we'll make do with a simple implementation.

 

One way to make it completely smooth in my opinion is to use double-smoothing

using the RMS to set the bias of the MA but there is a section that has no calculated data

Every MA has its own one as the lag increases depending on the smoothing period.

When using the indicator NoLagMA this lag is expressed in the coefficient 6.8541

in simple terms it can be expressed in a table...

8 1
13 1
21 2
34 3
55 5
89 8

this ratio was first obtained in a purely illustrative way through forced bias,

and then by using the RMS it was confirmed

The final variant for clarity is shown in the picture, which at first glance shows a smoothed and clearly superimposed picture...but there is one peculiarity, which is that the initial calculated data for the latest data will always have distorted display information, but the smaller the period, the less this distortion is. It is possible to reduce the distortion on higher periods by using the option of calculating the lower period on the higher TF and then approximating the missing points by smoothing...

 
Neutron писал(а) >>

Come on, we've already found a solution.

The problem is in the area where the coefficients w1, w2 and w3 are defined. Since in derivation of the functional we did not limit ourselves in any way with respect to their values, it is logical (probably) to put one of them identically equal to 1 (it is w3), and to connect the other two as in Bulashov's case. Then we obtain a one-parameter expression for the filter:

Here. Quite simple and tasteful! This is good. Now we can code for sure.

P.S. In general, it would be good if people who know DSP and filter-building basics could help us to define the area of determination of these coefficients (all three). As far as I remember, you need to find a characteristic equation and satisfy that its roots were inside a unit circle on the complex plane. This will allow you to work with a stable filter and fine-tune all its three knobs. But for now, we'll make do with a simple implementation.

It doesn't look smooth.

This is with different coefficients.

Although the smaller the coefficient, the smoother the sweep. Still interesting.

Files:
 
Neutron писал(а) >>

Come on, we've already found a solution.

The problem is in the area where the coefficients w1, w2 and w3 are defined. Since in derivation of the functional we did not limit ourselves in any way with respect to their values, it is logical (probably) to put one of them identically equal to 1 (it is w3), and to connect the other two as in Bulashov's case. Then we obtain a one-parameter expression for the filter:

Here. Quite simple and tasteful! This is good. Now we can code for sure.

P.S. In general, it would be good if people who know DSP and filter-building basics could help us to define the area of determination of these coefficients (all three). As I remember, you need to find a characteristic equation and satisfy that its roots were inside a unit circle on the complex plane. This will allow you to work with a stable filter and fine-tune all its three knobs. But for now we'll make do with a simple implementation.

If I'm not mistaken (I'll check when I get home) you've got known from Kalman filtering alpha-betta filter

 
Vinin >> :

It doesn't look smooth.

It's with different ratios.

Although the lower the coefficient, the smoother the wagon. Still interesting.

Oh, great!

It doesn't matter if it's not smooth at all, the main thing is that it is the one that must obtain the maximal rate of profit growth when trading at extremums (with all the caveats mentioned above). Vinin, why don't you provide us with the MTS for testing the MAKS?

By the way, notice that the extrema are exactly at the intersection of the kotir with the MA. I remember the requirement of this intersection from the books on theanalysis... It's all interesting.


Prival >> :

If I'm not mistaken (I'll check it when I get home), you've got the known Kalman filter alpha-betta


So, alpha or betta,-)

forte928 >> :

...but there is one peculiarity, which is that the initial computed data for the latest data will always have distorted mapping information...

He's redrawing. Yes?
Reason: