AvgDeviationArray (Function)

image\trumpet2.gif Disclaimer

The AvgDeviationArray function calculates the average difference between the array values and the array average.

Syntax

AvgDeviationArray(PriceArray,Size)

Returns (Double)

A numeric value for a specified array, for the current bar.  If no average calculation is performed as a result of improper array sizing or reference, the function will return -1.

Parameters

Name Type Description
PriceArray Numeric Array Specifies the name of a numeric array containing values upon which the average deviation is calculated.
Size Numeric Sets the number of data elements (size) in the array to evaluate.

Remarks

AvgDeviation is a measure of the variability in a data set.

The AvgDeviationArray function first calculates a standard average (mean) of the specified PriceArray using the Length input parameter for the number of trailing bars. Next it measures the absolute difference (ABSValue, which removes the negative sign) of each array data element from the mean and averages the sum of the differences.

The value for the Size input parameter should always be a whole number greater than 0 and is typically equal to the number of data elements in the array.

The AvgDeviationArray function only works with one-dimensional arrays.    The first element of the array that is used by this function is element 1. Element 0 of the array is not used.

Example

Assigns to Value1 the 10 bar average deviation from the mean for a specified array.

Array: myArray[10](0);

{… (assign values to array) }

Value1 = AvgDeviationArray (myArray, 10);