What is wrong with Bollinger's buffer values

 

Hi all,

Please look at the picture below.

The red lines are drawn by the value which is provided with iBands function.

What is wrong with them?

Why they are not matched with Bollingers end points?

(The upper band value is normalized just to see if there was difference (but not))


here is the code

   double Bollinger_UpperBand_Buffer[];
   double Bollinger_LowerBand_Buffer[];
   double Bollinger_MidleBand_Buffer[];

   ArraySetAsSeries(Bollinger_UpperBand_Buffer, true);
   ArraySetAsSeries(Bollinger_LowerBand_Buffer, true);
   ArraySetAsSeries(Bollinger_MidleBand_Buffer, true);



   int BollingerHandle=iBands(Sembol,Periyot,20,0,2,MODE_CLOSE);

   CopyBuffer(BollingerHandle,1,0,3,Bollinger_UpperBand_Buffer);
   CopyBuffer(BollingerHandle,2,0,3,Bollinger_LowerBand_Buffer);
   CopyBuffer(BollingerHandle,0,0,3,Bollinger_MidleBand_Buffer);

   double MyUpperBandValue=NormalizeDouble(Bollinger_UpperBand_Buffer[1],6);
   double MyMiddleBandValue=Bollinger_MidleBand_Buffer[1];
   double MyLowerBandValue=Bollinger_LowerBand_Buffer[1];

   ObjectMove(ChartID(),"BollingerUP",0,0,MyUpperBandValue);
   ObjectMove(ChartID(),"BollingerDown",0,0,MyLowerBandValue);
   ObjectMove(ChartID(),"BollingerMid",0,0,MyMiddleBandValue);


 
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010
 
William Roeder:
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

thanks a lot. (btw I also did it it provide nothing in that occasion. I ll revise it.

 
William Roeder:
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

I don't think that is the problem. Because answer didn't solve it.

I think there is really a bug or something with it.

 
Now, Im experiencing same issue with copybuffer Bollinger Bands on mql5. It's a bug going arround, its copy the slightly different value sometimes, which is very confusing. So i decide back to mql4
rather than fighting with this bug, which is cause by the plaftorm
 
Gede Ariawan #:
Now, Im experiencing same issue with copybuffer Bollinger Bands on mql5. It's a bug going arround, its copy the slightly different value sometimes, which is very confusing. So i decide back to mql4
rather than fighting with this bug, which is cause by the plaftorm
There is no bug with BB on mql5.
 
From the documentation 

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

It's clear that you used them wrongly. 
Fix your code.
 

Good morning
I confirm, no error in the code

I put two BBs on my terminal
The BB of the terminal and one of my codes which redoes the BBs

Exactly the same values

The code is there

Free download of the 'Bands Bollinger code for beginners by William210' indicator by 'William210' for MetaTrader 5 in the MQL5 Code Base, 2023.08.31



Bands Bollinger code for beginners by William210
Bands Bollinger code for beginners by William210
  • www.mql5.com
Bands Bollinger beginner tutorial to learn how to code in MQL5