MQL5 Boilinger Bands returns same value for all buffers

To add comments, please log in or register
Rynardtk
22
Rynardtk  

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:

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.

Stanislav Ivanov
7172
Stanislav Ivanov  

Hi,

I am curious, can you show a copy of the prints ?

And also , do you set the arrays to be buffers like 

SetIndexBuffer

?

Best Regards

Rynardtk
22
Rynardtk  
Stanislav Ivanov:

Hi,

I am curious, can you show a copy of the prints ?

And also , do you set the arrays to be buffers like 

?

Best Regards

Hi Stanislav,

Here is the output of one of the prints.

2020.07.11 09:06:35.681 2020.01.02 01:20:01   Boilinger Values - Upper: 6677.19999999996; Middle: 6677.19999999996; Lower: 6677.19999999996

I've printed those with the following command:

Print("Boilinger Values - Upper: ",BU[0],"; Middle: ", BM[0], "; Lower: ", BL[0]);

I set the buffer with the CoppyBuffer's 2nd parameter, which is the indicator's buffer number parameter, i.e. 0, 1, or 2.

This works for all of the other indicators with multiple buffers, however, just not with the Boilinger bands.

Vladimir Karputov
Moderator
207731
Vladimir Karputov  
Rynardtk :


Do you want to get the value from iBands from the advisor or from the indicator?

Vladimir Karputov
Moderator
207731
Vladimir Karputov  

An example of get values from the iBands indicator

iBands values on a chart

Рис. 1.  iBands values on a chart

How to start with MQL5
How to start with MQL5
  • 2020.07.05
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
Rynardtk
22
Rynardtk  
Владимир Карпутов :

An example of get values from the iBands indicator


Dear Vladimir,

Thanks for the answer, however the iGetArray method does not exist.

I use CopyBuffer, and the second CopyBuffer parameter should be the buffer number of the indicator you need.

So, I have 3 separate CopyBuffer commands, each for buffer 0, 1 and 2, which copy the values to 3 separate arrays.

When I print the values of 3 different arrays, all the values are the same for Upper, Middle and Lower respectively.

I use the same method on other indicators with several buffers, and it works fine, for example, the Keltner indicator, etc., but not with the Boyling bands.

Respectfully,

Rynardt

Rynardtk
22
Rynardtk  

I found the answer,

Apparently when you initialise the Boilinger bands, and you do not use the deviation of more than 0, all of your results are the same, for Upper, Middle and Lower bands.

When I now initialise the iBands with a deviation of 2, then I get different results for the different buffers.

Kind Regards,

Rynardt

Vladimir Karputov
Moderator
207731
Vladimir Karputov  
Rynardtk :

Dear Vladimir,

Thanks for the answer, however the iGetArray method does not exist.

I use CopyBuffer, and the second CopyBuffer parameter should be the buffer number of the indicator you need.

So, I have 3 separate CopyBuffer commands, each for buffer 0, 1 and 2, which copy the values to 3 separate arrays.

When I print the values of 3 different arrays, all the values are the same for Upper, Middle and Lower respectively.

I use the same method on other indicators with several buffers, and it works fine, for example, the Keltner indicator, etc., but not with the Boyling bands.

Respectfully,

Rynardt

Did you run the code? Why are you trying to ask something, but you are too lazy to even run the code?

I specifically showed the simplest and most elementary example. My code is working.

Please, if you ask for help - have a conscience and read the answers. Have a conscience and run the sample code that you are given.

Vladimir Karputov
Moderator
207731
Vladimir Karputov  
Rynardtk :

I found the answer,

Apparently when you initialise the Boilinger bands, and you do not use the deviation of more than 0, all of your results are the same, for Upper, Middle and Lower bands.

When I now initialise the iBands with a deviation of 2, then I get different results for the different buffers.

Kind Regards,

Rynardt

First learn how to work with 'shift' equal to '0'.

Until you learn basic techniques, you are forbidden to move on.

Vladimir Karputov
Moderator
207731
Vladimir Karputov  

An example of obtaining data if you set the horizontal offset for the indicator:


Rynardtk
22
Rynardtk  
Vladimir Karputov:

First learn how to work with 'shift' equal to '0'.

Until you learn basic techniques, you are forbidden to move on.

Seriously dude.

I know how to read documentation and this is also not the first time I'm doing this.

Some things did change from MQL4 to MQL5, and your example DOES NOT WORK.

I did run the code, perhaps you don't understand English and did not grasp the question in the first place.

What a place to even ask a question if this is the type of answers you get.  You should seriously get an attitude adjustment.

I got the stuff working without your crappy non-working example, thank you.

Perhaps you have this attitude because I didn't use your way of doing things.  Thank goodness I don't have to work in the same space as you do.

A forum is supposed to assist people in any possible means, or should I now start giving you advice on how to be a human being.

Seriously, rather read the question and then properly answer it next time.

12
To add comments, please log in or register