iBandsOnArray

Calculates the Bollinger Bands® indicator on data stored in an array and returns its value.

Function Signature

double iBandsOnArray(
  double array[],       // Array with data
  int total,            // Number of elements (0 for whole array)
  int period,           // Averaging period
  double deviation,     // Deviation (standard deviations)
  int bands_shift,      // Bands shift relative to chart
  int mode,             // Indicator line index (MODE_MAIN, MODE_UPPER, MODE_LOWER)
  int shift             // Shift relative to current bar
);

Parameters

  • array[]: Array containing the price data.
  • total: The number of elements to consider in the array. 0 means the entire array.
  • period: The averaging period for calculating the main line.
  • deviation: The number of standard deviations from the main line.
  • bands_shift: The indicator's horizontal shift relative to the chart.
  • mode: The indicator line to retrieve. Accepts values from the Indicators line identifiers enumeration (e.g., MODE_MAIN (0), MODE_UPPER (1), MODE_LOWER (2)).
  • shift: The index of the value from the indicator buffer, specifying the offset from the current bar (e.g., 0 for the current bar, 1 for the previous bar).
  • Return Value

    Returns the numerical value of the Bollinger Bands® indicator calculated on the provided array data.

    Notes

  • Unlike iBands(), this function does not use symbol name, timeframe, or applied price. Price data must be prepared beforehand.
  • The indicator calculates from left to right. To access array elements from right to left (as a series array), use the ArraySetAsSeries() function.
  • Example

    if(iBandsOnArray(ExtBuffer, total, 2, 0, 0, MODE_LOWER, 0) > Low[0]) return(0);
    

    Related Functions

  • iBands()
  • iBullsPower()