# Error in iBands when used in EA

107

I am using the function iBands in an EA to evaluate whether the 3 Bollinger Bands are rising. Herefore I look at the last closed bar and the one before last closed bar on a 1 hour chart.

For the Middle Band, Upper Band and Lower Band I get correct values in the EA when I compare with the Data Window on my screen, but with 1 exception wich is the value for the Upper Band of the last (most recent) closed bar.

I am using the following syntax to get the value of the Upper Band of the last closed bar: where 20 is the period for the middle band, 0 is the band shift and 0.382 is the factor for the standard deviation that I use.

Upper_Band_1  = iBands(NULL,0,20,0,0.382,PRICE_CLOSE,MODE_UPPER,1);

The syntax that I use for the other Bands and the second closed bar is simular.

When I use the function iCustum(.......) in combination with the Bands function I also get the wrong value for the Uppe rBand of the last closed bar.

My Questions:

1: Can anyone reproduce this error?

2: Has anyone a solution?

2: How to proceed in order to solve this problem?

3243

try:

```   while (iClose(Symbol(), PERIOD_H1, 0) == 0)
Sleep(500);
Upper_Band_1  = iBands(NULL,PERIOD_H1,20,0,0.382,PRICE_CLOSE,MODE_UPPER,1);
```
15577

robspaan: Upper_Band_1  = iBands(NULL,0,20,0,0.382,PRICE_CLOSE,MODE_UPPER,1);
iBands - MQL4 Documentation
```double  iBands(
string       symbol,           // symbol                      NULL
int          timeframe,        // timeframe                   PERIOD_H1
int          period,           // averaging period            20
double       deviation,        // standard deviations         0
int          bands_shift,      // bands shift                 0.382
int          applied_price,    // applied price               PRICE_CLOSE
int          mode,             // line index                  MODE_UPPER
int          shift             // shift                       1
);```
What is a BB with ZERO standard deviations? What is the meaning of a fractional shift?
107

WHRoeder:
iBands - MQL4 Documentation
What is a BB with ZERO standard deviations? What is the meaning of a fractional shift?

You are correct,  I had exchanged the variables for standard deviation and bands shift.

Thanks for your hawks eye. Problem is solved.

107

qjol:

try:

The problem was that I had exchanged the place for standard deviation and bands shift. Problem is solved.