Download MetaTrader 5

Error in iBands when used in EA

To add comments, please log in or register
The Market has more than 400 indicators. Try any of them!
Rob Spaan
107
Rob Spaan 2014.07.07 12: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
3243
qjol 2014.07.07 13:46  

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); 
whroeder1
14514
whroeder1 2014.07.07 17: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?
Rob Spaan
107
Rob Spaan 2014.07.07 19:34  
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.

Rob Spaan
107
Rob Spaan 2014.07.07 19:36  
qjol:

try:


The problem was that I had exchanged the place for standard deviation and bands shift. Problem is solved.
To add comments, please log in or register