//compile// //+------------------------------------------------------------------+ //| AcceleratorArrows.mq4 | //| Copyright © 2009, Robert Hill | //| | //| Written by Robert Hill for use with Accellerator History method | //| from thread at Forex Fatory | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Robert Hill" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LawnGreen #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 extern int shift = 61; extern bool OnlyNewArrows = false; int myShift; double UpArrow[]; double DownArrow[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY); SetIndexArrow(0, 233); SetIndexBuffer(0, UpArrow); SetIndexStyle(1, DRAW_ARROW, EMPTY); SetIndexArrow(1, 234); SetIndexBuffer(1, DownArrow); myShift = MathAbs(shift); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; double acc_cur, acc_prev; 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 = 1; i <= limit; i++) { for(i = limit; i >=0; i--) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; UpArrow[i] = 0; DownArrow[i] = 0; acc_cur = iAC(NULL, 0, i+myShift); acc_prev = iAC(NULL, 0, i+myShift+1); if (OnlyNewArrows) { if (acc_cur < 0 && acc_prev >= 0) { UpArrow[i] = Low[i] - Range*0.75; } else if (acc_cur >= 0 && acc_prev < 0) { DownArrow[i] = High[i] + Range*0.75; } } else { if (acc_cur < 0 ) { UpArrow[i] = Low[i] - Range*0.75; } else if (acc_cur >= 0 ) { DownArrow[i] = High[i] + Range*0.75; } } } return(0); }