Time: 2016-02-25 | Download file:Fractals_-_adjustable_period_extended.mq4
//+------------------------------------------------------------------+ //| Fractals - adjustable period | //+------------------------------------------------------------------+ #property link "www.forex-tsd.com" #property copyright "www.forex-tsd.com" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DeepSkyBlue #property indicator_color2 PaleVioletRed //#property indicator_width1 2 //#property indicator_width2 2 // // // // // extern int FractalPeriod = 25; extern double UpperArrowDisplacement = 0.2; extern double LowerArrowDisplacement = 0.2; extern int SizeArrow = 0;//размер extern int SimvolArrow= 159;//вид 33-255 double UpperBuffer[]; double LowerBuffer[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { if (MathMod(FractalPeriod,2)==0) FractalPeriod = FractalPeriod+1; SetIndexBuffer(0,UpperBuffer); SetIndexStyle(0,DRAW_ARROW,EMPTY,SizeArrow); SetIndexArrow(0,SimvolArrow); SetIndexBuffer(1,LowerBuffer); SetIndexStyle(1,DRAW_ARROW,EMPTY,SizeArrow); SetIndexArrow(1,SimvolArrow); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int start() { int half = FractalPeriod/2; int i,limit,counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=MathMin(MathMax(Bars-counted_bars,FractalPeriod),Bars-1); // // // // // for(i=limit; i>=0; i--) { bool found = true; double compareTo = High[i]; for (int k=1;k<=half;k++) { if ((i+k)compareTo) { found=false; break; } if ((i-k)>=0 && High[i-k]>=compareTo) { found=false; break; } } if (found) UpperBuffer[i]=High[i]+iATR(NULL,0,20,i)*UpperArrowDisplacement; else UpperBuffer[i]=UpperBuffer[i+1]; // // // // // found = true; compareTo = Low[i]; for (k=1;k<=half;k++) { if ((i+k) =0 && Low[i-k]<=compareTo) { found=false; break; } } if (found) LowerBuffer[i]=Low[i]-iATR(NULL,0,20,i)*LowerArrowDisplacement; else LowerBuffer[i]=LowerBuffer[i+1]; } return(0); }