Error in iBands when used in EA

Back to topics list To post a new topic, please log in or register
robspaan 2014.07.07 14:58

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? 

qjol 2014.07.07 15:46 #


   while (iClose(Symbol(), PERIOD_H1, 0) == 0)
   Upper_Band_1  = iBands(NULL,PERIOD_H1,20,0,0.382,PRICE_CLOSE,MODE_UPPER,1); 
WHRoeder 2014.07.07 19:10 #
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?
robspaan 2014.07.07 21:34 #
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.

robspaan 2014.07.07 21:36 #


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

To add comments, please log in or register