Value of BollingerBands on Indicator

 

I need the value of the BollingerBand-lines, which apply on indicator data.

If I use the iBands or iCustom function, I have no possibility to choose that it belongs to an indicator

and I don't want to write down the code for every line of the BB to find out if it got crossed.

 
  1. copy the bands.mq4 to say bandsOnIndicator.mq4
  2. Add an extra buffer.
  3. replace the
       for(i=0; i<limit; i++)
          MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
    
    with
      for(i=limit-1; i >= 0; i--){
          priceBuffer[i] = iCustom(..., i);
          MovingBuffer[i]= iMAOnArray(priceBuffer, BandsPeriod, BandsShift, MODE_SMA, i);
      }
  4. Replace your iBands code with iCustom(NULL,0, "bandsOnIndicator" ...)
 
tak88js:

I need the value of the BollingerBand-lines, which apply on indicator data.

If I use the iBands or iCustom function, I have no possibility to choose that it belongs to an indicator

and I don't want to write down the code for every line of the BB to find out if it got crossed.


iBandsOnArray was the solution. Too easy to find it in the first place!
 

You said you need "BollingerBand-lines, which apply on indicator data." That implies you don't have the indicator code.

Had you said you want to MODIFY an indicator and ADD BBs you would have gotten iBandsOnArray first.

Reason: