NEED HELP: Simple example function on how to calculate the minimum index value over the last x bars of bollinger upper -lower band

 

Hey guys,

i am new to coding and want to identify when the spread of bollinger bands (upper -lower band) reaches a minimum over the last x bars. Can anyone help me write a simple function that returns the corresponding index value?


I declared...

void OnTick(void)

  {

   double LowerBand,UpperBand; 

   double StdDev,BBDist; 

... and defined ...

 UpperBand = iBands(NULL,0,MATrendPeriod,3,0,PRICE_CLOSE,MODE_UPPER,0);

  LowerBand = iBands(NULL,0,MATrendPeriod,3,0,PRICE_CLOSE,MODE_LOWER,0);

   BBDist = UpperBand-LowerBand;


The problem now is that i do not know how to easy store the values of BBDist into an array and running min./max. calculations on it.


Thank you in advance for your assistance in case of your help.


Kind regards

tbm

 
No need for an array, just loop, find the distance, see if it's the smallest and remember the size and bar.
 
whroeder1:
No need for an array, just loop, find the distance, see if it's the smallest and remember the size and bar.


Thanks a lot for your quick respons whroeder1 ;)

I think I am to new to coding for this... can you give me a small example on how it would look like? Unfortunately I do not know how to use a corresponding loop function.

Best regards

tbm