//+------------------------------------------------------------------+ //| Reverse No Repair.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_color1 clrRed #property indicator_width1 1 #property indicator_type1 DRAW_ARROW #property indicator_color2 clrBlue #property indicator_width2 1 #property indicator_type2 DRAW_ARROW input int FilterCandle=12; double bufferUp[]; double bufferDown[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,bufferUp,INDICATOR_DATA); SetIndexBuffer(1,bufferDown,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_ARROW,233); PlotIndexSetInteger(1,PLOT_ARROW,234); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); ArraySetAsSeries(bufferDown,true); ArraySetAsSeries(bufferUp,true); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- ArraySetAsSeries(low,true); ArraySetAsSeries(high,true); int limit; if(prev_calculated>0) limit=rates_total-prev_calculated -1; else limit=rates_total -1; for(int i=limit; i>=0; i--) { bufferUp[i]=0; bufferDown[i]=0; if(i+FilterCandle+2iLow(Symbol(),0,preIndex) && iHigh(Symbol(),0,index)>iHigh(Symbol(),0,preIndex) && iClose(Symbol(),0,index)>iClose(Symbol(),0,preIndex) ) { int startIndex=preIndex+1; int endIndex=preIndex+FilterCandle-1; for(int i=startIndex; i<=endIndex; i++) { if(iLow(Symbol(),0,i)iHigh(Symbol(),0,preIndex)) { flag=false; break; } } } else { flag=false; } return flag; } //+------------------------------------------------------------------+