PureBytes Links
Trading Reference Links
|
Mark Jurik <mark@xxxxxxxxxxxx> wrote:
> An improved version is
> Method 2) if MRO(C <= C[1], N, 1 ) < 0 then ....
> which examined only the bars in question. However, there is still
> excessive redudancy here because if the last N bars did not meet
> the test, then why re-examine the same N-1 bars one bar later.
Actually, the MRO approach is a bit more efficient than that. If you
look at the MRO code you will see that it exits its loop as soon as
it finds the Nth most recent occurence. So, in this example, as soon
as any bar is found where C <= C[1], MRO exits. This solution still
has the function-call overhead (which may possibly be larger than the
loop time) and the looping until it finds the C <= C[1] case, but
it's not quite as bad as you thought.
> if C>C[1] then value1 = value1 + 1;
> if value1 - value1[N] = N then .....
> This approach, although very clever, runs the risk of integer
> overflow as value1 keeps incrementing ad infinitum.
Not a huge risk for most people, but worth noting if it really is
possible.
However, Mark, does TS really use integers for the value1
computation? I have always assumed that ALL TS variables were
floats, since any numeric variable CAN take on a floating-point value
at any time. I'd be very surprised if the EL compiler is smart
enough to detect the integer-only math in the example above, given
the general level of language sophistication in EL.
Gary
|