You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The line coefficients a and b are calculated in these lines.
A = (SumXY - N3*SumY)*N4;
B = (N1*SumY - SumXY)*N2;
For illustration, I attach MovingLR_2 version that just draws the current linear regression. Especially, because there was a mistake in previous one, when calculating N4 :)
MovingLR_2 gives pure linear regression and it's pretty easy to make sure of that. In at_LR0 there is inaccuracy of change from period in hours to period in bars. If you change Close in at_LR0 to (High+Low)/2 and take a period of 1, and change the period in MovingLR_2 to 61 instead of 60 and display it on the one-minute chart, the results will be exactly the same.
Well then MovingLR_2 is a good algorithm, just tweak the code layout and it's ok!
In at_LR0 the one bar offset is done to fit the linear regression from MT4 standard toolkit. Maybe this didn't need to be done...
2 zigan:
For linear regression, the formula is: LRMA = 3*LWMA - 2*MA
For quadratic regression:
Quadratic Regression MA = 3 * SMA + QWMA * ( 10 - 15/( N + 2 ) ) - LWMA * ( 12 - 15/( N + 2 ) )
Here N is the period of the averages,
QWMA( i; N ) = 6/( N*(N+1)(2*N+1) ) * sum( Close[i] * (N-i)^2; i = 0...N-1 ) (the square-weights machine).
for cubic: oops, still can't get it out of Trading Solutions, my formula is too wild there.
2 Candid: you're really paranoid, I wouldn't have thought of it...
I got different formulas.
where is
a little tweaking of the code layout, and everything is OK!
2 Yurixx:
It seems that the difference in RMS values for small N is not due to RMS correction, but to the choice of start and direction X. Because when you change them my former formula also starts to give different results, and it is accurate without any reservations.
2 Yurixx:
It looks like the difference in RMS values for small N is not due to RMS correction, but to the choice of start and direction X. Because when you change them my old formula starts giving different results too, while it is accurate without any reservations.
You are certainly right that the correct choice of coordinate system is a powerful technique to simplify the calculations and the appearance of the final formulas. I did not use it for linear regression, everything turned out nice enough. But for parabolic regression, given a certain choice of origin, final expressions turn out to be twice as easy, while effectiveness of the algorithm increases by an order of magnitude. In addition, the problem of limitations on the accuracy of calculations is completely removed.
I cannot agree with you on one point, however. RMS values, as well as the actual regression values, cannot depend on the choice of the origin of the X-axis. Perhaps it's not the formula itself that starts giving different results but the very issue of calculation accuracy becomes apparent. Since only 15 significant digits of double are stored (let alone int), an error is accumulated rather quickly in the process of calculations. This is especially true when X and Y have different orders of magnitude. For example, X is a bar number of the order of hundreds of thousands, Y is a price of the order of 1 and the price change is of the order of 0.0001.
PS
I wanted to understand what makes this formula "tasty". Obviously, it's much simpler - in one line. Although I don't understand why you divide by (N-2) and not by (N-1). I should still note that, aiming for maximum acceleration, you would have to use a different formula. If you fix the choice of origin X in relation to the current price value, it is more advantageous to use formulas without Sum(X*Y). Then you won't have to calculate the convolution on every bar. But to update Sum(Y*Y) or Sum(X*X) on every bar is one operator.
If you know the current value of coefficients A and B in a linear regression, can you calculate the RMS
here are the formulas
coefficient A
coefficient B
If you know the current value of coefficients A and B in a linear regression, can you calculate the RMS
P.S. I just remembered that QWMA is quadratic by X and I'll need a term quadratic by Y. So QWMA won't help.
If you know the current value of coefficients A and B in a linear regression, can you calculate the RMS
QWMA probably won't be enough either, as it doesn't square Y and therefore doesn't determine the variance of Y.
One thing, however, I cannot agree with you. The RMS values, as well as the regression values themselves, cannot depend on the choice of starting point for the X-axis. Perhaps it's not the formula itself that starts giving different results, but this very problem of calculation accuracy.
Although I don't understand why you divide by (N-2) and not by (N-1).
P.S. For Sum(Y*Y) - I also have three operations, for Sum(X*X) - none.
Quadratic Regression MA = 3 * SMA + QWMA * ( 10 - 15/( N + 2 ) ) - LWMA * ( 12 - 15/( N + 2 ) )
QWMA( i; N ) = 6/( N*(N+1)(2*N+1) ) * sum( Close[i] * (N-i)^2; i = 0...N-1 ) (a square-weighted wizard).
I got other formulas.
where