//+---------------------------------------------------------------------+ //| ZP_WPR-OBV_v02.mq4 | //| Copyright © 2009, Ron Mauldin | //| | //| William's Percent Range Crossed With On Balance Volume | //| | //| This indicator is a modification of William's Percent Range. | //| In WPR, I replaced the 'period close' with On Balance Volume. | //| This was simply a way to introduce volume into my favorite | //| indicator. //| The outcome is very interesting with mixed results. | //| • On the plus side, it is like an enhanced WPR in that it is | //| still a leading signal that usually leads even WPR. | //| • On the minus side, sometimes it gives totally bogus signals. | //| If you figure out how to stop the bogus signals or can even | //| Identify what causes the bogus signals... please drop me a line. | //| | //| Collaborators Wanted | //| Do you have an interesting idea or indicator designed for scalping? | //| Would you like to collaborate and turn it into an EA trading robot? | //| If I like your idea, I will help you fully analyze it. | //| If the analysis is good, then I will help you turn your idea into | //| an EA robot that we will both share. | //| | //| Are you a "quality" MT4 programmer with "plenty of time" to work on | //| joint venture (JV) projects? | //| If so, I have plenty of ideas and would like to discuss a JV. | //| | //| NOTE!!! | //| I am NOT looking for back-testers or programmers for hire. | //| I am looking for entrepreneurial technical analysts or programmers | //| who really believe that well coded forex robot could make millions.| //| Please don't yank my chain if you are not serious about hard work. | //| | //| Email: ronmauldin51-mt4 at yahoo dot com | //| | //| This is the forex broker I use: fx41.com | //+---------------------------------------------------------------------+ #property copyright "Copyright © 2009, Ron Mauldin" #property link "ronmauldin51-mt4 at yahoo dot com" #property indicator_separate_window #property indicator_minimum -100 #property indicator_maximum 0 #property indicator_buffers 2 #property indicator_color1 Black #property indicator_color2 DodgerBlue #property indicator_level1 -20 #property indicator_level2 -80 extern int WPR_Period = 6; //---- buffers double obvBuffer[]; double wprBuffer[]; //+------------------------------------------------------------------+ //| ZP_WPR-OBV indicator initialization function | //+------------------------------------------------------------------+ int init(){ IndicatorShortName("ZP_WPR-OBV("+WPR_Period+")"); IndicatorBuffers(2); SetIndexBuffer(0,obvBuffer); SetIndexStyle(0,DRAW_LINE); SetIndexLabel(0,"OBV"); SetIndexBuffer(1,wprBuffer); SetIndexStyle(1,DRAW_LINE); SetIndexLabel(1,"WPR-OBV"); return(0); } //+------------------------------------------------------------------+ //| WPR Using On Balance Volume | //+------------------------------------------------------------------+ int start(){ // int bar,nLimit,nCountedBars; //Indicator Variables double obvOpen,obvClose; double obvMaxHigh,obvMinLow; // Standard variables int bar,MaxBar, limit, counted_bars = IndicatorCounted(); // Standard loop setup MaxBar=WPR_Period; if(Bars-1 < MaxBar) return(0); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; MaxBar = Bars - 1 - MaxBar; limit = (Bars - 1 - counted_bars); //---- initialization of buffer nulls if(limit > MaxBar){ for(bar = Bars - 1; bar >= MaxBar; bar--) { obvBuffer[bar] = 0.0; wprBuffer[bar] = 0.0; } limit = MaxBar; } //+--- Basic loop to populate the OBV buffer for(bar = limit; bar >= 0; bar--){ if(bar==Bars-1)obvBuffer[bar]=Volume[bar]; else{ obvOpen=Close[bar+1]; obvClose=Close[bar]; if(obvClose==obvOpen)obvBuffer[bar]=obvBuffer[bar+1]; else if(obvClose= 0; bar--){ obvMaxHigh = obvBuffer[ArrayMaximum(obvBuffer,WPR_Period,bar)]; obvMinLow = obvBuffer[ArrayMinimum(obvBuffer,WPR_Period,bar)]; if(!CompareDouble((obvMaxHigh - obvMinLow), 0.0)) wprBuffer[bar] = -100*(obvMaxHigh - obvBuffer[bar]) / (obvMaxHigh - obvMinLow); } return(0); } //+------------------------------------------------------------------+ bool CompareDouble(double Number1, double Number2) { bool Compare = NormalizeDouble(Number1 - Number2, 8) == 0; return(Compare); } //+------------------------------------------------------------------+