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
Yura, I want to count the RMS faster than the standard function. What if it works? For a single call it should be faster than any code written in the language, but for mass (whole chart calculation) it is possible to save on costs.
If we are talking about sco for linear regression, it is calculated analytically in one step by the formula
SKO^2=D[Y] - D[X]*A^2,
where D[Y]=M[Y^2]-M[Y]^2, D[X]=M[X^2]-M[X]^2, and A is the linear regression coefficient Y=A*X+B
So recurrence is not needed here.
PS And cross sums are zeroed out explicitly and purely analytically. Sample size has nothing to do with it.
Still an error 2008.02.15 17:07:22 2007.01.11 12:15 OTF_1 EURUSD,M1: negative argument for MathSqrt function
That's why the only thing I can think of, just in case, is to execute lambda=0.0;
and/or MathSqrt(MathAbs(lambda*lambda*lambda*lambda)) to get rid of this error forever.
//---- main loop
double alpha, lambda=0.0 ;
//********************************************************************************************
for (i = limit; i >= 0; i--)
{
Price[i]=(High[i]+Low[i])/2.0;
}
for (i = limit; i >= 0; i--)
{
Value1[i]=SC*(Price[i]-Price[i+1])+4*SC*Value1[i+1];
Value2[i]=SC*(High[i]-Low[i])+4*SC*Value2[i+1];
}
for (i = limit; i >= 0; i--)
{
if(Value2[i]< Point)Value2[i]= Point;else lambda=MathAbs(Value1[i]/Value2[i]);
alpha=(-lambda*lambda+ MathSqrt(lambda*lambda*lambda) )/8.0;
Value3[i]=alpha*Price[i]+(1.0-alpha)*Value3[i+1];
}
//********************************************************************************************
P.S. Generally nonsense. This error must be popping up in your tester.
P.P.S. Most likely, the variable double lambda; was initialized by default with very small negative rubbish. Then the double lambda=0.0; expression should help.
Slava teaches us - never work by default, and we do not learn!
Still an error 2008.02.15 17:07:22 2007.01.11 12:15 OTF_1 EURUSD,M1: negative argument for MathSqrt function
P.S. That's crazy. Is this error probably popping up in your tester?
P.P.S. Most likely, the variable double lambda; was initialized by default with very small negative rubbish. Then the double lambda=0.0; expression should help.
Slava teaches us - never work by default, and we do not learn!
Local botniks are always trying to invent some bicycle.
Don't sweat it for nothing. Among custom indices there is Bands.mq4 - there is an algorithm of RMS calculation
SKO^2=D[Y] - D[X]*A^2,
where D[Y]=M[Y^2]-M[Y]^2, D[X]=M[X^2]-M[X]^2, and A is linear regression coefficient Y=A*X+B
So recurrence is not needed here.
And what do you mean recurrence is unnecessary, how are the sums supposed to be calculated? Or do you have an idea how to do without replacing expectation by the average?
P.S. By the way, cross sums do not leave by themselves. At least I did not. Try to work not with variance but with "real" expression
Hence for linear regression it is
Consequently, for a linear regression it would be
SKO^2=D[Y] - D[X]*A^2,
where D[Y]=M[Y^2]-M[Y]^2, D[X]=M[X^2]-M[X]^2, and A is linear regression coefficient Y=A*X+B
So recurrence is not needed here.
And what do you mean recurrence is not needed, how are the sums supposed to be calculated? Or do you have an idea how to avoid replacement of expected payoffs with a mean?
P.S. By the way, cross sums do not leave by themselves. At least I did not. Try to work not with variance but with "real" expression
Very eager to know what could be superfluous in these formulas ? :-)
MO is, of course, replaced by the mean and sums have to be calculated. However, recurrence or even a cycle is not needed. The following formula will suffice
S(X)[i+1]=S(X)[i] - X[i-N+1] + X[i+1] where S(X)[i]=Sum(X[k]; k=i-N+1, i-N+2, ...,i-1,i )
Well, maybe you mean this expression when you speak of recurrence? Then, of course, you're right.
As for "real expression", where do you think all these formulas come from ? Well, if you substitute into this "real expression" the finite formulas derived from the MNC for A and B, then you get just the above expression for RMS. I can give you the corresponding analytical calculations.
I can give you the relevant analytical calculations.
If it's not too much trouble to elaborate from here. With new data the coefficients A and B may change, I think, although I may be wrong :-). For LR it seems to be solved, but for parabolic regression how ?
This is by definition. If LR is not too short, you can calculate RMS more accurately, without any extra cycle. There is a code for RMS calculation in the source MovingLR.mq4, but it is commented out and RMS is called rmsY.