PureBytes Links
Trading Reference Links
|
I have a function for calculating r-squared which I am unsuccesfully
trying to convert from series to simple.
Here's the code:
++++++++++++++++++++++++++++++++++++++
{Function: AV_R2}
Inputs: Len(Numeric) ;
Vars: X(0), UpEQ(0), LowEQ1(0), LowEQ2(0), LowEQT(0), R(0), R2(0) ;
X = BarNumber;
UpEQ = Summation(X * Close, Len) - (Len * Average(X, Len) *
Average(Close, Len));
LowEQ1 = Summation(Square(X), Len) - (Len * Square(Average(X, Len)));
LowEQ2 = Summation(Square(Close), Len) - (Len *Square(Average(Close,
Len)));
LowEQT = SquareRoot(LowEQ1 * LowEQ2);
If LowEQT <> 0 Then R = UpEQ / LowEQT;
AV_R2 = Square(R) ;
+++++++++++++++++++++
Now when I change the properties manually to simple, I get an error
message saying that references to previous values are not allowed, with
X being highlighted in the second line of code (UpEQ = ...).
I just don't see this. I tried replacing X = BarNumber with X =
CurrentBar and X = X + 1, but with the same results.
Can anybody tell me what's going on or how to convert this function to
simple?
Thanks,
Cab Vinton
cvinton@xxxxxxxxxxx
|