//+------------------------------------------------------------------+ //| VininI_ZZ11.1.mq4 | //| Copyright © 2010, Victor Nicolaev. | //| vinin@mail.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Victor Nicolaev." #property link "vinin@mail.ru" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Yellow #property indicator_color3 Yellow extern int BarsCount=15; // количество баров для расчета ZZ extern int ZZCount=1; double ZZ[]; double MA_DN[], MA_UP[]; double ZZValue[][2]; int ZZTime[2]={0,0}; int Id; int UP=0; int DN=1; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0, ZZ); SetIndexBuffer(1, MA_UP); SetIndexBuffer(2, MA_DN); // небольшая защита для корректности работы if (BarsCount<2) BarsCount=2; SetIndexStyle(0, DRAW_SECTION); SetIndexStyle(1, DRAW_LINE); SetIndexStyle(2, DRAW_LINE); ArrayResize(ZZValue,ZZCount); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit=Bars-counted_bars-1; if(Bars-counted_bars > 2) { ArrayInitialize(ZZ,EMPTY_VALUE); limit=Bars-BarsCount-1; int posHigh = iHighest( NULL, 0, MODE_HIGH, BarsCount, limit); int posLow = iLowest( NULL, 0, MODE_LOW, BarsCount, limit); ZZ[posHigh]=High[posHigh]; ZZ[posLow]=Low[posLow]; ZZTime[0]=MathMax(Time[posHigh],Time[posLow]); ZZTime[1]=MathMin(Time[posHigh],Time[posLow]); Id=UP; if (posHigh>posLow) Id=DN; } for(int i=limit; i>=0; i--) { ZZWork(i); double tmp_UP=0, tmp_DN=0; for (int j=0;jposLow) { posmax=posHigh; posmin=posLow; Valuemax=High[posHigh]; Valuemin=Low[posLow]; } if ((ZZ[prevpos2]-ZZ[prevpos1])*(ZZ[prevpos1]-Valuemin)<0) { ZZTime[1]=ZZTime[0]; Id=UP; if (ZZ[prevpos1]-Valuemin<0) Id=DN; for (int j=ZZCount-1;j>0;j--) ZZValue[j, Id]=ZZValue[j-1,Id]; } else ZZ[prevpos1]=EMPTY_VALUE; ZZ[posmin]=Valuemin; ZZTime[0]=Time[posmin]; ZZValue[0, Id]=Valuemin; }