Cannot get the values of the lower band of the Bollinger Band

 

Hello,

I want to retreive the value of the lower band of the Bollinger bands. I tried the following code :

ArraySetAsSeries(lower_band,true);
handle=iBands(NULL,0,20,2.0,0,PRICE_CLOSE);
CopyBuffer(handle,2,0,2,lower_band);

The value I get for lower_band[1] is the central value (base_band[1]) of the indicator and not the higher or lower band value. 

I tried other parameters with the same result.

Any idea ? 

Bollinger Bands ®
  • votes: 14
  • 2010.01.26
  • MetaQuotes Software Corp. | English Russian Chinese Spanish Portuguese
  • www.mql5.com
The Bollinger Bands ® Indicator (BB) is similar to Envelopes. The only difference is that the bands of Envelopes are plotted a fixed distance (%) away from the moving average, while the Bollinger Bands are plotted a certain number of standard deviations away from it.
 

Try this code:

int handle;
double lower_band[];
ArraySetAsSeries(lower_band,true);
handle=iBands(NULL,0,20,0,2.0,PRICE_CLOSE);
CopyBuffer(handle,2,0,2,lower_band);
Print(lower_band[0]);


Bogdan Baltatu, mqlmagazine.com

MQLmagazine.com | All things MetaTrader
  • mqlmagazine.com
Portfolio expert advisors, as well as the more complex multiasset expert advisors, were awaited by the retail trading community ever since limitations of the MT4 backtester became obvious, that is, about 4 – 5 years ago. The difference between multiasset and portfolio EAs is that multiasset EAs have... Read more »
 

Thanks, it works !

But the Help file is not well written and it should be corrected. Here is a copy of the iBands Help file :

 

int  iBands(
   string              symbol,            // symbol name
   ENUM_TIMEFRAMES     period,            // period
   int                 bands_period,      // period for average line calculation
   double              deviation,         // number of standard deviations
   int                 bands_shift,       // horizontal shift of the indicator
   ENUM_APPLIED_PRICE  applied_price      // type of price or handle
   ); 
Lines 5 and 6 are inverted, which misled me.
 
danielth:

Thanks, it works !

But the Help file is not well written and it should be corrected. Here is a copy of the iBands Help file :

 

Lines 5 and 6 are inverted, which misled me.
We'll fix it tomorrow. Sorry.
 

Hello Mr Rosh, 

I've just downloaded the Help File.

The order of the parameters have not been changed yet and inversion between lines 5 and 6 (Shift and Deviation) remains.

 

It's a bit strange because it was changed in the online version of Documentation- iBands:

The function returns the handle of the Bollinger Bands indicator.

int  iBands(
   string              symbol,            // symbol name
   ENUM_TIMEFRAMES     period,            // period
   int                 bands_period,      // period for average line calculation
   int                 bands_shift,       // horizontal shift of the indicator
   double              deviation,         // number of standard deviations
   ENUM_APPLIED_PRICE  applied_price      // type of price or handle
   );



 

I've just downloaded and checked - it's OK. You should get the latest version from https://www.mql5.com/files/docs/mql5.chm (1.4 Mb)


 

Thank you for your answer.

I have downloaded the Help File as indicated (mine, dated 27Jan2010, was obviously not the latest one - but didn't update automatically ?)

However, when I doubleclick the File, only the left window works properly, the right one showing : "Navigation cancelled - try again the address"

Any clue to this problem ?

 
danielth:

However, when I doubleclick the File, only the left window works properly, the right one showing : "Navigation cancelled - try again the address"

Any clue to this problem ?

It's the eternal question - https://www.mql5.com/en/forum/112960
file MQl4BookEnglish.chm is broken.... - MQL4 forum
  • www.mql5.com
file MQl4BookEnglish.chm is broken.... - MQL4 forum
 

Sorry

I didn't know