Download MetaTrader 5

bollinger band trend detect?

To add comments, please log in or register
yeah016
26
yeah016  
Hi, is that anyway can detect bb trend(iband)? ranging up/down or flat?  please help. Thanks.
Carl Schreiber
7239
Carl Schreiber  
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.
yeah016
26
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?
Ernst Van Der Merwe
5040
Ernst Van Der Merwe  
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);
yeah016
26
yeah016  
pipPod:
Thanks a million !!!
Ernst Van Der Merwe
5040
Ernst Van Der Merwe  
yeah016:
Thanks a million !!!
You're welcome.
yeah016
26
yeah016  
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

Ernst Van Der Merwe
5040
Ernst Van Der Merwe  

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; 

Chang Suk Chung
573
Chang Suk Chung  
pipPod:

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

Chang Suk Chung
573
Chang Suk Chung  
Thanks
To add comments, please log in or register