//+------------------------------------------------------------------+ //| VininI_BB.mq4 | //| Copyright © 2011, Victor Niclolaev aka Vinin | //| vinin@mail.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Victor Niclolaev aka Vinin" #property link "vinin@mail.ru" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Yellow #property indicator_color2 Yellow #property indicator_color3 Red //--- input parameters extern int period=30; extern double kStDev=1.0; extern int Shift=0; //--- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexShift(0, Shift); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexShift(1, Shift); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexShift(2, Shift); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { IndicatorDigits(Digits); int counted_bars=IndicatorCounted(); int pos, limit=Bars-counted_bars; if (limit>1) { pos=Bars-period-1; double price=iMA(NULL, 0, period, 0, MODE_SMA,PRICE_CLOSE,pos); double delta=iStdDev(NULL,0,period, 0, MODE_SMA, PRICE_CLOSE, pos)*kStDev; ExtMapBuffer1[pos]=price+delta; ExtMapBuffer2[pos]=price-delta; if (High[pos]>ExtMapBuffer1[pos]) { ExtMapBuffer1[pos]=High[pos]; ExtMapBuffer2[pos]=High[pos]-2.0*delta; } if (Low[pos]=0;pos--) { price=ExtMapBuffer3[pos+1]; delta=iStdDev(NULL,0,period, 0, MODE_SMA, PRICE_CLOSE, pos)*kStDev; ExtMapBuffer1[pos]=ExtMapBuffer1[pos+1]; ExtMapBuffer2[pos]=ExtMapBuffer2[pos+1]; if (High[pos]>ExtMapBuffer1[pos]) { ExtMapBuffer1[pos]=High[pos]; ExtMapBuffer2[pos]=High[pos]-2.0*delta; if (ExtMapBuffer2[pos]ExtMapBuffer1[pos+1]) ExtMapBuffer1[pos]=ExtMapBuffer1[pos+1]; } ExtMapBuffer3[pos]=(ExtMapBuffer1[pos]+ExtMapBuffer2[pos])*0.5; } return(0); } //+------------------------------------------------------------------+