Bollinger Bands Mismatch

 

I'm trying to use iBands to retrieve the Bollinger Bands lower and upper values but for some reason the data does not march the visual chart (created by the same iBands function call).

Sometimes it's above, sometimes it's below... doesn't seams to follow a pattern.

Any Advice?

double upper = iBands(NULL, 0, 20, 2, 0, MODE_CLOSE, MODE_UPPER, 1);
double lower = iBands(NULL, 0, 20, 2, 0, MODE_CLOSE, MODE_LOWER, 1);
ObjectSet("Upper", OBJPROP_PRICE1, upper);
ObjectSet("Lower", OBJPROP_PRICE1, lower);   
 
hvilela:

I'm trying to use iBands to retrieve the Bollinger Bands lower and upper values but for some reason the data does not march the visual chart (created by the same iBands function call).

Sometimes it's above, sometimes it's below... doesn't seams to follow a pattern.

Any Advice?

I just realized that there's a message at journal that says:

2013.12.03 20:54:43     BollingerBands inputs: bands_period=10; bands_derivation=3; 

When I use this parameters, it matches.

Why would it use 10 and 3 instead of 20 and 2 (that i'm passing as parameter)?

 
hvilela:

I just realized that there's a message at journal that says:

When I use this parameters, it matches.

Why would it use 10 and 3 instead of 20 and 2 (that i'm passing as parameter)?

I'm guessing you also have the Bollinger Bands indicator attached to your chart ? set to period = 10 and derivation = 3 ?
 
RTFM
double upper = iBands(NULL,    0,                   20,            2,            0,          MODE_CLOSE,  MODE_UPPER,      1);
double iBands(  string symbol, int timeframe, int period, int deviation, int bands_shift, int applied_price, int mode, int shift
Reason: