[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Better Method



PureBytes Links

Trading Reference Links

pierre.orphelin@xxxxxxxxxx écrit:
> Unfortunately not.
> The MRO function is not coded internaly and uses EL code.

Right you are.  I just assumed a function like that would be 
internally coded for speed, and never even thought to look in the 
function list.  Careless of me.

A few people asked me if MRO executes the "test" condition Length 
times every time you call MRO.  Examining the MRO code shows that the 
function does, indeed, use the Easy Language feature of storing 
values in a MaxBarsBack-long array, so that it only has to evaluate 
the test condition once on every bar.  (It accesses previous values 
of the test condition via Expr[J].)

BTW, MRO is coded intelligently enough to drop out of its loop as 
soon as it finds the Nth most recent occurance.  So unless you 
actually do have more than Length consecutive bars with C>C[1], Bob's 
original solution will run just as fast as my minor improvement, and 
faster than my original simple loop.  (Though both our solutions will 
be significantly slower than Pierre's.)

> This specific code fragment might be about 20-30x faster, yes.  (You
> can't predict an exact 22x improvement, given the other differences,
> e.g. loop overhead and "barsback array" overhead in my example.)
> ===
> Yes, and I was considering only the loop length that is the main
> duration between two codes. Otherwise it's not a linear problem, as
> you pointed out. 

Yes, I was sure you knew that, Pierre.  I just wanted to make it 
clear to the watchers of this trivia exchange.  :-)

Gary