//+------------------------------------------------------------------+ //| Bands.mq4 | //| Copyright (c) 2009, Plamo-Bite Corp. | //| http://fx7-signal.com/store/ | //+------------------------------------------------------------------+ #property copyright "Copyright (c) 2009, Plamo-Bite Corp." #property link "http://fx7-signal.com/store/" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 White //---- indicator parameters extern int BandsPeriod=20; extern int BandsShift=0; extern double BandsDeviations=2.0; //---- buffers double MovingBuffer[]; double UpperBuffer[]; double LowerBuffer[]; double GapBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0,GapBuffer); SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2); //---- SetIndexDrawBegin(0,BandsPeriod+BandsShift); //---- return(0); } //+------------------------------------------------------------------+ //| Bollinger Bands | //+------------------------------------------------------------------+ int start() { int i,k,counted_bars=IndicatorCounted(); double deviation; double sum,oldval,newres; //---- if(Bars<=BandsPeriod) return(0); int limit=Bars-counted_bars; for(i=limit-1;i>=0;i--){ GapBuffer[i]=iBands(NULL,0,BandsPeriod,BandsDeviations,BandsShift,PRICE_CLOSE,MODE_UPPER,i)-iBands(NULL,0,BandsPeriod,BandsDeviations,BandsShift,PRICE_CLOSE,MODE_LOWER,i); } //---- return(0); } //+--------------------------------------------------