MQL5 - Bollinger Buffers displaying same values

#property copyright "Adam"
#property link      ""
#property version   "1.00"

int bbHandle;

void OnInit()

   bbHandle = iBands(Symbol(),PERIOD_CURRENT,20,2,0,PRICE_CLOSE);

void OnTick()

   double upbb[];
   double lwbb[];
   double mibb[];
   Comment(upbb[1], "|", lwbb[1], "|", mibb[1]);



I have lurked on a lot of posts but this is my first actual post so hi!

I'm learning to code MQL5 and I have tried to use buffers to copy the last values of the Bollinger bands to arrays, from which the values are then commented. For some reason the comment displays the same data 3 times:

I can't get my head around it, it's not important I'm doing it purely for the purposes of learning but it is driving me nuts! I have checked the documentation on iBands and Buffers but for someone inexperienced like myself this often leaves me more confused than I was before.

Thank you in advance,


   bbHandle = iBands(Symbol(),PERIOD_CURRENT,20,2,0,PRICE_CLOSE);

Check your parameters.

Alain Verleyen:

Check your parameters.

Thank you Alain, that is embarrasing on my skills as a trader... not a new developer lol
Alain Verleyen:

Check your parameters.

I have encountered another issue with this today, I have tried for hours to get it right but I just cannot seem to diagnose the issue, nor find any help online and it's so frustrating!

double Open[];

double iOpen(string symbol(),ENUM_TIMEFRAMES timeframe, int index)


   double open=0;
   int copied=CopyOpen(symbol(),timeframe,0,Bars(symbol(),timeframe),Open);
   if(copied>0 && index<copied) open=Open[index];

double previous_open = iOpen(Symbol(),PERIOD_CURRENT,1);

The following error messages are being displayed:

Thank you in advance and apologies for being so dense

double _Open[];

double iOpen(string symbol,ENUM_TIMEFRAMES timeframe, int index)

   double open=0;
   int copied=CopyOpen(symbol,timeframe,0,Bars(symbol,timeframe),_Open);
   if(copied>0 && index<copied) open=_Open[index];
also CopyOpen, CopyBuffer and other timeseries related copy functions, need a array (of type double often) as the last parameter.
Good day,

I hope someone could please advise me.

In MQL5 I initialize my Boilinger bands with the iBands call:
fastBoilinger_handle = iBands(_Symbol, _Period, 20, 0, 0, PRICE_CLOSE);
I then try to get the upper, middle and lower band values for the past 3 time frames as follows:
   double BM[], BU[], BL[];
   ArraySetAsSeries(BM, true);
   ArraySetAsSeries(BU, true);
   ArraySetAsSeries(BL, true);

   int Data = CopyBuffer(fastBoilinger_handle, 0, 0, 3, BM);
   int Data2 = CopyBuffer(fastBoilinger_handle, 1, 0, 3, BU);
   int Data3 = CopyBuffer(fastBoilinger_handle, 2, 0, 3, BL);
As per the documentation for iBands:

The buffer numbers are the following: 0 - BASE_LINE, 1 - UPPER_BAND, 2 - LOWER_BAND

But when I do a simple test by just printing the values out, all of the buffers contain the exact same value.
Any help in the matter would be much appreciated.