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

Re: Not Average



PureBytes Links

Trading Reference Links

In the second case, you are using the variable "diff" for two things. Try 
the following:

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

In addition there will be an error in the first few bars because of 
initialization.

The following version will be correct for all bars plotted:

   Plot1(Average(C - C[1], 3), "diff");

This is because it uses no extra variables that have to be initialized.

Bob Fulks



At 08:16 AM 7/9/2003, Ian Waugh wrote:

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?