Bollinger Bands on Chart and iBands are different

 
Hello all

Please shed some light on this discrepancy with iBands and the bands on the chart.  

Print (iBands(_Symbol,PERIOD_M5, 20,3,0,Ask, MODE_UPPER,0));

This line should give me the current upper value of the Bollinger Band on the 5min chart (with 3 standard deviations).

The result is printed as 1.1558:


But on the chart, the current value is 1.15594.  As the price goes higher, the bands on the chart adapt, but iBands doesn't report this.

This is a problem - as you can see my program paused when the price was 1.5581 instead of the correct Bollinger value on the chart.



Thanking everyone who can reply.





Files:
 
Shawn Cranko:
Hello all

Please shed some light on this discrepancy with iBands and the bands on the chart.  

Print (iBands(_Symbol,PERIOD_M5, 20,3,0,Ask, MODE_UPPER,0));

This line should give me the current upper value of the Bollinger Band on the 5min chart (with 3 standard deviations).

The result is printed as 1.1558:


But on the chart, the current value is 1.15594.  As the price goes higher, the bands on the chart adapt, but iBands doesn't report this.

This is a problem - as you can see my program paused when the price was 1.5581 instead of the correct Bollinger value on the chart.



Thanking everyone who can reply.





Read the documentation for iBands

 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Your code
    Documentation
    iBands(
    _Symbol,
    PERIOD_M5, 
    20,
    3,
    0,
    Ask, 
    MODE_UPPER,
    0
    )
    double  iBands(
       string       symbol,           // symbol
       int          timeframe,        // timeframe
       int          period,           // averaging period
       double       deviation,        // standard deviations
       int          bands_shift,      // bands shift
       int          applied_price,    // applied price
       int          mode,             // line index
       int          shift             // shift
       );

    What applied_price are you using?

 

Thanks, will post there in future.  

I've used Ask as the applied price.  I think that's correct is it not?  I've tried PRICE_HIGH, Bid, Open[0], Close[0]...

They all give me a different value to what the chart is saying.


William Roeder #:
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Your code
    Documentation

    What applied_price are you using?

 
I don’t think it matters the timeframe… price is price… all I can see is that it is about 3 min difference between your Print and your cross on the chart… maybe that is way
 

I set the back-test to pause as the price moves above the 3rd deviation.

if (Ask > iBands(_Symbol,thisPeriod, 20,3,0,Ask, MODE_UPPER,0)) {

      PauseTest();

   }


So, iBands gives 1.1558, while the chart reads 1.15594, and my program is pausing before a true crossing and the price is still actually under the 3rd deviation. 

   

Daniel Cioca #:
I don’t think it matters the timeframe… price is price… all I can see is that it is about 3 min difference between your Print and your cross on the chart… maybe that is way
 
Shawn Cranko #: I've used Ask as the applied price.  I think that's correct is it not?  I

I gave you the link to what an applied price is. Ask is a price, a double, 1.23450. That is not!

 

It looks like some kind of rounding error,  that's what I figure anyways.



Shawn Cranko:
Hello all

Please shed some light on this discrepancy with iBands and the bands on the chart.  

Print (iBands(_Symbol,PERIOD_M5, 20,3,0,Ask, MODE_UPPER,0));

This line should give me the current upper value of the Bollinger Band on the 5min chart (with 3 standard deviations).

The result is printed as 1.1558:


But on the chart, the current value is 1.15594.  As the price goes higher, the bands on the chart adapt, but iBands doesn't report this.

This is a problem - as you can see my program paused when the price was 1.5581 instead of the correct Bollinger value on the chart.



Thanking everyone who can reply.





 
Shawn Cranko #:

It looks like some kind of rounding error,  that's what I figure anyways.



2 things, as one of the forum gods has tried to hint to you is that you can not use Ask or Bid, AND if i remember correctly, the buffers for UPPER and Lower bands is different on the indicator. So you have 2 issues.

but yes there is a rounding issue, but you can fix this by using and modifying the indicator to suite your needs.
Reason: