//+------------------------------------------------------------------+ //| fractals - adjustable period.mq5 | //+------------------------------------------------------------------+ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" #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 Red #property indicator_color2 DeepSkyBlue #property indicator_label1 "Fractal Up" #property indicator_label2 "Fractal Down" #property indicator_width1 2 #property indicator_width2 2 // // // // // input int FractalPeriod = 24; // Fractal period (will be made odd for even input) input int ArrowShift = 10; // Vertical shift in pixels for arrows // // // // // double ExtUpperBuffer[]; double ExtLowerBuffer[]; // // // // // int iFractalPeriod; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnInit() { if (MathMod(FractalPeriod,2)==0) iFractalPeriod = FractalPeriod+1; else iFractalPeriod = FractalPeriod; SetIndexBuffer(0,ExtUpperBuffer,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_ARROW,159); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-ArrowShift); SetIndexBuffer(1,ExtLowerBuffer,INDICATOR_DATA); PlotIndexSetInteger(1,PLOT_ARROW,159); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT, ArrowShift);} // // // 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 &TickVolume[], const long &Volume[], const int &Spread[]) { if(rates_total=compareTo) { found=false; break; } if ((i-k)>=0 && High[i-k]> compareTo) { found=false; break; } } if (found) ExtUpperBuffer[i]=High[i]; else ExtUpperBuffer[i]=EMPTY_VALUE; // // //---- Lower Fractal // // found = true; compareTo = Low[i]; for (int k=1;k<=half;k++) { if ((i+k)=0 && Low[i-k]< compareTo) { found=false; break; } } if (found) ExtLowerBuffer[i]=Low[i]; else ExtLowerBuffer[i]=EMPTY_VALUE; } // // // // // return(rates_total); }