//6/15/2010 - Fixed indicators logic to plot arrow on bearish bars above EMA or bullish bars below EMA #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Yellow #property indicator_color2 Yellow double Up[]; double Down[]; int xflag=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY,1); SetIndexArrow(0, 225); SetIndexBuffer(0, Up); SetIndexStyle(1, DRAW_ARROW, EMPTY,1); SetIndexArrow(1, 226); SetIndexBuffer(1, Down); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double EMA1, EMA2; double Range, AvgRange; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 0; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; EMA2 = iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, i+2); EMA1 = iMA(NULL, 0, 100, 0, MODE_EMA, PRICE_CLOSE, i+1); if (Close[i+1]>EMA1) xflag=1; if (Close[i+1]Close[i+1]) { xflag=0; Up[i+1] = Low[i+1] - Range*0.5; } } if (xflag==2) { if (Open[i+1]