Download MetaTrader 5

bollinger band trend detect?

To add comments, please log in or register
Download MQL5 library codes via MetaTrader. It is convenient!
yeah016
26
yeah016 2016.06.13 04:48 
Hi, is that anyway can detect bb trend(iband)? ranging up/down or flat?  please help. Thanks.
Carl Schreiber
6610
Carl Schreiber 2016.06.13 23:18  
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 2016.06.15 06:39  
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
4735
Ernst Van Der Merwe 2016.06.15 09:09  
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 2016.06.17 12:47  
pipPod:
Thanks a million !!!
Ernst Van Der Merwe
4735
Ernst Van Der Merwe 2016.06.18 09:06  
yeah016:
Thanks a million !!!
You're welcome.
yeah016
26
yeah016 2016.06.20 02:28  
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
4735
Ernst Van Der Merwe 2016.06.20 13:49  

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
528
Chang Suk Chung 2016.07.01 14:41  
pipPod:

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

Chang Suk Chung
528
Chang Suk Chung 2016.07.01 14:43  
Thanks
To add comments, please log in or register