bollinger band trend detect?

 
Hi, is that anyway can detect bb trend(iband)? ranging up/down or flat?  please help. Thanks.
 
yeah016:
Hi, is that anyway can detect bb trend(iband)? ranging up/down or flat?  please help. Thanks.

google for bb and how to interpret them and/or use them..

Or just look at the end of the page all forums there is an example of using BB in an EA: https://www.mql5.com/en/code/14209.

Auto Trade with BB
Auto Trade with BB
  • votes: 6
  • 2016.06.09
  • Khurram Mustafa
  • www.mql5.com
Auto trading with the help of some indicators.
 
Hi Thanks for reply, I know how to interpret BB is ranging or flat, just in EA, what is the method/formula to let the EA determine it?
 
yeah016:
Hi Thanks for reply, I know how to interpret BB is ranging or flat, just in EA, what is the method/formula to let the EA determine it?
double currUpper=iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,0);
double currLower=iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_LOWER,0);
double prevUpper=iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_UPPER,1);
double prevLower=iBands(NULL,0,20,2.0,0,PRICE_CLOSE,MODE_LOWER,1);

if(MathAbs((currUpper-currLower)-(prevUpper-prevLower))<100*_Point)  //less than 10 pip difference between current and previous bands - flat
   return(0);
 
pipPod:
Thanks a million !!!
 
yeah016:
Thanks a million !!!
You're welcome.
 
pipPod:
You're welcome.

Hi PipPod, after I tested, seem like this method also not so accurate to detecting the BB flag or ranging as it compare previous value and current value.

currently I tried on other formula something like below.

MathArctan(MathTan(((price1-price2)/(WindowPriceMax()- WindowPriceMin()))/((SignalPeriod-0.0)/WindowBarsPerChart())))*180/3.14;


Or maybe you have more accurate formula to detect BB patern?  Thanks in advance

 

I'd rather use a range with the same period.

//---
      double max =-1000000;
      double min = 1000000;
//---
      for(int k=BandsPeriod;k>0;k--)
        {
         //---
         if(High[k]>max)
            max=High[k];
         if(Low[k]<min)
            min=Low[k];
        }
//---
      MathArctan(MathTan(((Close[0]-close[BandsPeriod])/(max-min))/((BandsPeriod-0.0)/BandsPeriod)))*180/M_PI; 

 
pipPod:

I'd rather use a range with the same period.

 
Thanks
Reason: