//+------------------------------------------------------------------+ //| BWI.mq4 | //| Copyright © 2007, ProjectSomewhere.com. | //| http://www.ProjectSomewhere.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, ProjectSomewhere.com." #property link "http://www.projectsomewhere.com/" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 DodgerBlue //---- input parameters extern int BWIPeriod=14; //---- buffers double BWIBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,BWIBuffer); //---- name for DataWindow and indicator subwindow label short_name="BWI("+BWIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); //---- SetIndexDrawBegin(0,BWIPeriod); //---- return(0); } //+------------------------------------------------------------------+ //| Momentum | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); //---- if(Bars<=BWIPeriod) return(0); //---- initial zero if(counted_bars<1) for(i=1;i<=BWIPeriod;i++) BWIBuffer[Bars-i]=0.0; //---- i=Bars-BWIPeriod-1; if(counted_bars>=BWIPeriod) i=Bars-counted_bars-1; while(i>=0) { BWIBuffer[i]=iBands(NULL,0,BWIPeriod,2,0,PRICE_CLOSE,MODE_UPPER,i)-iBands(NULL,0,BWIPeriod,2,0,PRICE_CLOSE,MODE_LOWER,i); i--; } return(0); } //+------------------------------------------------------------------+