MQL4 Reference Custom Indicators IndicatorBuffers


Allocates memory for buffers used for custom indicator calculations.

bool  IndicatorBuffers(
   int     count         // buffers



[in]  Amount of buffers to be allocated. Should be within the range between indicator_buffers and 512 buffers.

Returned value

true, if the amount of buffers has been changed successfully, otherwise false.


The amount of buffers cannot exceed 512 and be less than the value set in #property indicator_buffers. If a custom indicator requires additional buffers for counting, IndicatorBuffers() function should be used for specifying the total amount of buffers.


//|                                                        Bulls.mq4 |
//|                   Copyright 2005-2013, MetaQuotes Software Corp. |
//|                                     |
#property copyright   "2005-2013, MetaQuotes Software Corp."
#property link        ""
#property description "Bulls Power"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver
//--- input parameter
input int InpBullsPeriod=13;
//--- buffers
double ExtBullsBuffer[];
double ExtTempBuffer[];
//| Custom indicator initialization function                         |
void OnInit(void)
   string short_name;
//--- 1 additional buffer used for counting.
//--- drawing style
//--- name for DataWindow and indicator subwindow label
//| Bulls Power                                                      |
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
   int limit=rates_total-prev_calculated;
   for(int i=0; i<limit; i++)

See also

Custom Indicator Properties, Access to timeseries and indicators