PureBytes Links
Trading Reference Links
|
Chris Cheatham wrote:
>
> First thing I would suggest would be to streamline our code to only run when
> necessary (e.g., run only on price change) and to eliminate user function
> calls, which are slow.
Optimizing code is always a good thing. I don't know that calling
functions, in and of itself, is slow. The thing is to do the calc only
once and save the result as a var. Call the function once if you don't
want to paste in the function code but don't call the same function
repeatedly doing the same calc. Simple pseudocode example:
if average(c,100) > whatever then foo;
if average(c,100) < someother then bar;
is slower than
avg = average(c,100);
if avg > whatever then foo;
if avg < someother then bar;
The 'only run when necessary' bit means using simple functions which
only run when called, rather than series functions which run on every
bar. Some calcs need to run on every bar to keep track but others don't.
Bob Fulks has written some informative posts about that subject on the
list.
--
Dennis
|