//+------------------------------------------------------------------+ //| Fractals at Close prices.mq5 | //| Copyright © 208, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2018, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.000" #property description "Fractals at prices Close" //---- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_type1 DRAW_ARROW #property indicator_type2 DRAW_ARROW #property indicator_color1 clrGreen #property indicator_color2 clrGreen #property indicator_label1 "Fractal Up" #property indicator_label2 "Fractal Down" //---- indicator buffers double ExtUpperBuffer[]; double ExtLowerBuffer[]; //--- 10 pixels upper from high price int ExtArrowShift=-10; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- indicator buffers mapping SetIndexBuffer(0,ExtUpperBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtLowerBuffer,INDICATOR_DATA); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //---- sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_ARROW,217); PlotIndexSetInteger(1,PLOT_ARROW,218); //---- arrow shifts when drawing PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,ExtArrowShift); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-ExtArrowShift); //---- sets drawing line empty value-- PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- initialization done } //+------------------------------------------------------------------+ //| Accelerator/Decelerator Oscillator | //+------------------------------------------------------------------+ 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[]) { int i,limit; //--- if(rates_total<5) return(0); //--- if(prev_calculated<7) { limit=2; //--- clean up arrays ArrayInitialize(ExtUpperBuffer,EMPTY_VALUE); ArrayInitialize(ExtLowerBuffer,EMPTY_VALUE); } else limit=rates_total-5; for(i=limit;iclose[i+1] && close[i]>close[i+2] && close[i]>=close[i-1] && close[i]>=close[i-2]) ExtUpperBuffer[i]=close[i]; else ExtUpperBuffer[i]=EMPTY_VALUE; //---- Lower Fractal if(close[i]