CiBands always return the same for Upper, Lower and Base

 

Hello,

I've created a CiBands object:

private:
CiBands bollinger;

On the constructor:

bollinger.Create(symbol, PERIOD_H1, 20, 2, 0, PRICE_CLOSE);

On another method:

bollinger.Refresh(OBJ_ALL_PERIODS);
double upBollinger = bollinger.Upper(1);
double lowBollinger = bollinger.Lower(1);
double baseBollinger = bollinger.Base(1);  


Why upBollinger, lowBollinger and baseBollinger has the same value?
         

 
lqsa00: I've created a CiBands objec Why upBollinger, lowBollinger and baseBollinger has the same value?
  1. Because your code is broken.
  2. Code that we can't see.
 
whroeder1:
  1. Because your code is broken.
  2. Code that we can't see.

Sorry? I can't understand your answer. The code is the one that I publish. All together:

CiBands bollinger;

int OnInit()
{

bollinger.Create(Symbol(), PERIOD_H1, 20, 2, 0, PRICE_CLOSE);

}

void OnTick()
{
bollinger.Refresh(OBJ_ALL_PERIODS);
double upBollinger = bollinger.Upper(1);
double lowBollinger = bollinger.Lower(1);
double baseBollinger = bollinger.Base(1);

}

The values could be viewed on debugger or in the data window. No matter the date, always the three values are the same.

:




 
lqsa00: Sorry? I can't understand your answer. The code is the one that I publish. All together:
CiBands bollinger;
  1. You said
    I've created a CiBands object
    Which I took as you created that class. I apologize, (I'm not very familiar with the MT5 classes.)
  2. I can't see any problems with the code.
 
lqsa00:

Sorry? I can't understand your answer. The code is the one that I publish. All together:

The values could be viewed on debugger or in the data window. No matter the date, always the three values are the same.

:




Because you set your parameters incorrectly. Deviation is 0, so the 3 values are the same.

bollinger.Create(symbol, PERIOD_H1, 20, 2, 0, PRICE_CLOSE);
Documentation on MQL5: Standard Library / Indicators / Trend Indicators / CiBands / Create
Documentation on MQL5: Standard Library / Indicators / Trend Indicators / CiBands / Create
  • www.mql5.com
Standard Library / Indicators / Trend Indicators / CiBands / Create - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: