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

Re: Bug report & fix for Average_a function



PureBytes Links

Trading Reference Links

The TSPro version of this function has a comment which states that element 0 of
the array is ignored.

By an amazing coincidence I was looking at this function 30 mins before reading
Berselli's email!

I Smith

Berselli wrote:

>  OLD VERSION :
>
> {***********************************************************************
> Description : This Function returns the Average of an Array of values.
> Provided By : Omega Research, Inc. (c) Copyright 1999
> ************************************************************************}
>
> Inputs: AvgArray[size](NumericArrayRef), Array_Size(Numeric);
> Variables: Sum(0), Counter(0);
> {Array_Size is passed as an Input so that only the array elements that have
> been used are referenced}
>
> Sum = 0;
> Counter = 0;
>
> For value1 = 1 To Array_Size Begin  {<--** ERROR Value1=0 NOT Value1=1,**
> ERROR Array_Size-1 NOT Array_Size  }
>  Sum = Sum + AvgArray[value1];
>  Counter = Counter + 1;
> End;
>
> If Counter <> 0 Then
>  Average_a = Sum / Counter
> Else
>  Average_a = -1;
>
> DEBUGGED VERSION:
>
> ***********************************************************************
> Description : This Function returns the Average of an Array of values.
> Provided By : Omega Research, Inc. (c) Copyright 1999
> ************************************************************************}
>
> Inputs: AvgArray[size](NumericArrayRef), Array_Size(Numeric);
> Variables: Sum(0), Counter(0);
> {Array_Size is passed as an Input so that only the array elements that have
> been used are referenced}
>
> Sum = 0;
> Counter = 0;
>
> For value1 = 0 To Array_Size-1 Begin
>  Sum = Sum + AvgArray[value1];
>  Counter = Counter + 1;
> End;
>
> If Counter <> 0 Then
>  Average_a = Sum / Counter
> Else
>  Average_a = -1;
>
>
> ***********************
> Claudio Berselli