//+------------------------------------------------------------------+ //| OBV2.mq4 | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 DodgerBlue double gadblOBV[]; int init() { SetIndexBuffer( 0, gadblOBV ); SetIndexStyle( 0, DRAW_LINE ); IndicatorDigits( 0 ); IndicatorShortName( "OBV2" ); SetIndexLabel( 0, "OBV2" ); return( 0 ); } int start() { int intCountedBars = IndicatorCounted(); if ( intCountedBars > 0 ) intCountedBars--; int intLimit = Bars - intCountedBars - 1; for( int inx = intLimit; inx >=0; inx-- ) { if ( inx == ( Bars - 1 ) ) { gadblOBV[inx] = Volume[inx]; } else { if ( ( High[inx] == Low[inx] ) || ( Open[inx] == Close[inx] ) || ( Close[inx] == Close[inx+1] ) ) { gadblOBV[inx] = gadblOBV[inx+1]; } else { if ( Close[inx] > Open[inx] ) gadblOBV[inx] = gadblOBV[inx+1] + ( Volume[inx] * ( Close[inx] - Open[inx] ) / ( High[inx] - Low[inx] ) ); else gadblOBV[inx] = gadblOBV[inx+1] - ( Volume[inx] * ( Open[inx] - Close[inx] ) / ( High[inx] - Low[inx] ) ); } } } return( 0 ); }