Author's dialogue. Alexander Smirnov. - page 14

 
Yurixx:
Prival:

VBAG first posted 1 indicator, then replaced it with another one (I saw it all :-) ), and posted the third one, but already an expert. And I still cannot see the moving picture, which will convince me that the mathematician is right. The hard-headed military man is so "dumb" :-) on the blind faith does not take :-)


I don't know, Sergey, why you need moving pictures, but I can make you an indicator with 2 lines. One LRMA, the other 3*LWMA-2*MA. They will overlap completely, i.e. one of them will not be visible because of the other. You turn off the colour of the other one, you see the first one. You turn the colour on - you only see the other one.

I'd send you a proof of equivalence, too, it's short - only a dozen lines. But it relies on formulas that are derived analytically to implement linear regression. Well, not to count everything in numbers, and if possible to use finite formulas - the fewer cycles, the faster it is counted. But this is quite a long calculations, I do not want to mess around in Word.


Thanks. I'll try to do it myself. I need a distraction. I finally finished the Kalman filter. But I haven't been able to run it on the tester for a week. I am afraid if it works :-(. I'm looking for errors trying to prepare its data better and make the prediction even more accurate. It works in Matkadec, but I'm afraid to run it in the tester.

 
VBAG:
If you have more streamlined algorithms for calculating the dashes or regression, it would be very interesting to have a look!

Algorithms are too loud to call it, but I can give you an idea. The principle is simple: you win in speed, you lose in memory. Since the first one is required more, we load the memory.

For example, a simple SMA. The built-in algorithm must be universal and calculate it anywhere, regardless of the context. And you can use the results of previous calculations in your own program. In order to calculate the new SMA value, the sum of the previous N price values should be taken, the first one should be subtracted from it and the new, current value should be added. This sum is then divided by N. Hence, a variable with the sum of the previous N prices and the array of these N prices should be substituted and the sum and the array should be refreshed at every bar. As the result, to calculate SMA on each bar, we need to execute 3 operators: Update the sum, update the array element and calculate the SMA value. No loops.

 
Prival:

But I haven't been able to run it on the tester for a week now. I'm afraid it might work:-( .


Yes, that happens too. :-))
 
LeoV wrote:
Here is for example JMA and SSA with a period of 50. But I have CSSA based on SSA but not redrawing. Very fast. I recommend this algorithm.....

Off-topic, of course, but still interesting - LeoV, could you show me a picture of CSSA Cycles indicator of the same developer (looks very good on shares) ? I want to see how it looks on forex quotes.
 
Yurixx:
Such a method probably makes sense, but only if the periods are short. And memory is not the main reason. A reset will lose what we're dragging behind us. That's great, though. Thanks for the answer.
 
Prival:

The Kalman filter is finally finished.

I hear you're pushing the Kalman theme. I missed that discussion for some reason. Where can I see it?

P.S. I have attached a file on the subject - maybe someone will be interested.
 
Yes, if you call yourself a coward, you get in the box. OK, Sergey, here is a proof (I need it anyway, for my own confidence):

Let us have time samples - t = 1, 2, ... N. Numbering is reversed in MQL4, i.e. N is the current bar, "zero". These readings correspond to the clause Сlose(1), Сlose(2), ... Сlose(N). Let us try to construct a straight line y = A*t+B passing through the cloises by MNC. Then we calculate A*N + B, i.e. LRMA at the current bar.

We calculate the sum of error squares:

Delta^2 = Sum( ( y(i) - Close(i) )^2; i = 1..N ) = Sum( ( A*i + B - Close(i) )^2; i = 1..N )

We differentiate this stuff by A and B and get a system of equations for optimal A and B quotients:

Sum( ( ( A*i + B - Close(i) ) * i ); i = 1...N ) = 0
Sum( A*i + B - Close(i) ); i = 1...N ) = 0

Expanding the sums, we get (I omit index ranges to simplify the notation)

A*Sum( i^2 ) + B*Sum( i ) = Sum( i*Close(i) )
A*Sum( i ) + B*Sum( 1 ) = Sum( Close(i) )

Prival, now look at the right-hand sides. The sum on the right side of the first equation is almost LWMA, only without the normalizing factor. In the second, it is SMA, also without it. Here are the exact formulas for these scales:

LWMA = 2/(N*(N+1)) * Sum( i*Close(i) )
SMA = 1/N * Sum( Close(i) )

Now recall what the sum of the squares of natural 1 to N equals (it's N*(N+1)*(2*N+1)/6), substitute it into our system and we get:

A * N*(N+1)*(2*N+1)/6 + C * N*(N+1)/2 = LWMA * N*(N+1)/2
A * N*(N+1)/2 + C * N = SMA * N

Simplifying:

A * (2*N+1)/3 + C = LWMA
A * (N+1)/2 + C = SMA

I'm not going to solve the system, I'm too lazy (it's already clear here). I'll just multiply the first equation by 3, and the second by 2, and then subtract the second one from the first one:

A * (2*N+1) + 3 * C - A * (N+1) - 2 * C = 3 * LWMA - 2 * SMA

On the left, after simplification, A*N + B remains, i.e. exactly our regression at point N.
 
Alexey! Respect again! I've been wondering where the "/6" in my LRMA formula (or should I say Omega formula) comes from!
 
VBAG:
This method probably makes sense, but only if the periods are small. And memory is not the main reason. When restarting, what we drag behind us will be lost. But great, thanks for the answer.


This method is good for any periods. When you reboot, everything, of course, is lost. However, at startup, we can always first run this unsophisticated algorithm through the entire chart, creating the necessary information. Or it is possible not to run it on the whole graph, but only on a sufficient chunk of it.

This method has only one disadvantage - instead of one iMA you have to write some number of lines of code by your own hand. :-)

 

Alexei, thank you. I'll sit with a pencil. The derivatives of A and B are like this


I double-checked the answer, yes indeed A*N+B=3*LWMA-2*SMA

although the mathematician missed a deuce in taking the derivative.

and I have some doubts, that they should match not at point N, but at (N-1)/2. Bulashev p.156. It seems. Here is a picture that coincide at the point N. So I am rather wrong.

Reason: