MQL4 Reference Custom Indicators SetIndexBuffer

MQL4 Reference


The function binds a specified indicator buffer with one-dimensional dynamic array of the double type. There are two variants of the function.

bool  SetIndexBuffer(
   int                    index,         // buffer index
   double                 buffer[],      // array
   ENUM_INDEXBUFFER_TYPE  data_type      // what will be stored

Call without specifying of data type, stored in the indicator buffer.

bool  SetIndexBuffer(
   int                    index,         // buffer index
   double                 buffer[]       // array



[in] Number of the indicator buffer. The numbering starts with 0. The number must be less than the value declared in #property indicator_buffers.


[in]  An array declared in the custom indicator program.

Return Value

If successful, returns true, otherwise - false.


After binding, the dynamic array buffer[] will be indexed as in common arrays, even if the indexing of timeseries is pre-installed for the bound array. If you want to change the order of access to elements of the indicator array, use the ArraySetAsSeries() function after binding the array using the SetIndexBuffer() function. Please note that you can't change the size for dynamic arrays set as indicator buffers by the function SetIndexBuffer(). For indicator buffers, all operations of size changes are performed by the executing sub-system of the terminal.


  double ExtBufferSilver[];
  int init()
      SetIndexBuffer(0, ExtBufferSilver); // buffer of the first line
      // ...

See also

Custom Indicator Properties, Access to timeseries and indicators