imaonarray()
Previous  Next

imaonarray

Calculates the Moving Average indicator on data, stored in array, and returns its value.

double  imaonarray(
   double       array[],          // array with data
   int          total,            // number of elements
   int          ma_period,        // MA averaging period
   int          ma_shift,         // MA shift
   int          ma_method,        // MA averaging method
   int          shift             // shift
   );
Parameters

array[] :
[in]  Array with data.

total :
[in]  The number of items to be counted. 0 means the whole array.

ma_period :
[in]  Averaging period for calculation.

ma_shift :
[in]  MA shift. Indicators line offset relate to the chart by timeframe.

ma_method :
[in]  Moving Average method. It can be any of MA METHOD constants values.

shift :
[in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Returned value :
Numerical value of the Moving Average indicator, calculated on data, stored in array[].

Note :
Unlike ima(...), the imaonarray() function does not take data by timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right.

Example:

   double macurrent=imaonarray(ExtBuffer,0,5,0,MODE_LWMA,0);
   double macurrentslow=imaonarray(ExtBuffer,0,10,0,MODE_LWMA,0);
   double maprev=imaonarray(ExtBuffer,0,5,0,MODE_LWMA,1);
   double maprevslow=imaonarray(ExtBuffer,0,10,0,MODE_LWMA,1);
   //----
   if(maprev<maprevslow && macurrent>=macurrentslow)
     Alert("crossing up");