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

RE: Not Average



PureBytes Links

Trading Reference Links

I know that the subject was handling AVERAGES, and in that context Gary
Fritz' commentary was correct.

However, in the context of programming for simplicity and speed, what you
actually computing is the average diff per bar.  That's the total diff over
all the bars/#bars, or (last value - first value)/#values.  Everything
between first and last is canceling.  There is no need to average all the
bars.

The general formula is

QuickAvgDiffs = (Price - Price[Length})/Length;

so

Plot1((close - close[3])/3, "diff");

is equivalent and quicker than

Plot1(average(diff,3),"diff");

For a 3 bar average this isn't significant, but it would be a major speed
difference for a very long average.

Note: I agree with the comment of not performing calculations in Plots as a
matter of programming practice - these are shorter examples for clarity.

regards, daver





-----Original Message-----
From: Ian Waugh [mailto:ianwaugh@xxxxxxxxx]
Sent: Wednesday, July 09, 2003 8:16 AM
To: omega-list@xxxxxxxxxx
Cc: ianwaugh@xxxxxxxxxxxxxxxxxxx
Subject: Not Average


I'm having trouble with Average. Probably just not got my head around
something but would appreciate a pointer...

I'm calculating the difference between this bar's close and the previous
bar's close and trying to plot the 3-bar average but I get different
results depending on when the Average is taken. For example:

diff=c-c[1];
plot1(average(diff,3),"diff");

    produces a different plot to:

diff=c-c[1];
diff=average(diff,3);
plot1(diff,"diff");

I would have assumed they'd plot the same plot. Where am I going wrong?

Ian