i_Model_ZZ





//--------------------------------------------------------------------
// ind_Model_ZZ.mq4
// Âûáîð çèã-çàãà Êîñèöèíà îáóñëîâëåí òåì, ÷òî ïîñëå ïîÿâëåíèÿ
// êîí÷èêà, ïðåäûäóùèé óçåë óæå íå ïåðåðèñîâûâàåòñÿ
//--------------------------------------------------------------------
#property copyright "Copyright © 2008, BiViSi Corp."
#property link      "riderfin@bk.ru"
#property link      "ICQ 499494112"

#property indicator_chart_window    
#property indicator_buffers 3       
//---- ñòèëü  èíäèêàòîðíîé ëèíèè
#property indicator_color1 Blue 
#property indicator_color2 Red
#property indicator_color3 Yellow        
#property indicator_style1 0
#property indicator_style2 0
#property indicator_style3 1
#property indicator_width1 3
#property indicator_width2 2
#property indicator_width3 1
//---- ÂÕÎÄÍÛÅ ÏÀÐÀÌÅÒÐÛ ÈÍÄÈÊÀÒÎÐÀ 
extern int Depth=12;
extern int Deviation=5;
extern int Backstep=3;
extern int TFLarge=1440;
extern int TFMidle=240;
extern int TFSmall=60;

double ZZ_Large[],ZZ_Midle[], ZZ_Small[]; // Îáúÿâëåíèå ìàññèâîâ (ïîä áóôåðû èíäèêàòîðà)
double CurExt[5],TimeBars[5],CtrlTimes[]; //,CurMidle[5][1],CurSmall[5][1];
static datetime PrevTimeZigZagCalc;
static int CurPeriod;
//--------------------------------------------------------------------
int init() 
{
   SetIndexBuffer(0,ZZ_Large); SetIndexStyle(0,DRAW_SECTION); SetIndexEmptyValue(0,0.0); // ìîæåò áóôåðû òîæå ?????
   SetIndexBuffer(1,ZZ_Midle); SetIndexStyle(1,DRAW_SECTION); SetIndexEmptyValue(1,0.0); // â ôóíêöèè         ????? 
   SetIndexBuffer(2,ZZ_Small); SetIndexStyle(2,DRAW_SECTION); SetIndexEmptyValue(2,0.0); // èíèöèàëèçèðîâàòü  ????? 
   PrevTimeZigZagCalc=0; CurPeriod=Period();
   return;              
}
//--------------------------------------------------------------------
int start()
{
   // êîíòðîëü ÒÔ è ââåäåííûõ ïàðàìåòðîâ
   if (CurPeriod > TFSmall) {Alert ("Ïåðèîä ãðàôèêà äîëæåí áûòü ìåíüøå èëè ðàâåí ", TFSmall, " ìèí.");return;}
   if (TFSmall >= TFMidle || TFMidle >= TFLarge) {Alert ("Íåêîððêòíûé âûáîð òàéìôðåéìîâ äëÿ ðàñ÷åòà");return;}
   ZigZagCalc();
   return;
}
//======================================================================
// âû÷èñëåíèå óçëîâ çèãçàãà íà ñòàðøèõ ÒÔ è îòîáðàæåíèå íà òåêóùåì
//======================================================================
void ZigZagCalc ()
{   
   // âû÷èñëåíèå îäèí ðàç òîëüêî íà ïîëíîñòüþ ñôîðìèðîâàâøåìñÿ áàðå 
   if (PrevTimeZigZagCalc == Time[0]) return;
   // âû÷èñëåíèå "VolExt" ïîñëåäíèõ ýêñòðåìóìîâ íà ñòàðøèõ ÒÔ
   int i, x, y, k, VolExt=5, NumberExt, Per;   
   int sh, limit, dn, up;
   double zz_Dn, zz_Up;
   for (y=1; y<=3; y++)
      {
      if (y==1) Per=TFLarge; else if (y==2) Per=TFMidle; else Per=TFSmall;
      // Âû÷èñëÿåì èçëîìû òîëüêî ñ îêîí÷àíèåì ôîðìèðîâàíèÿ áàðà ñòàðøåãî ÒÔ
      int t=MathCeil(Time[0]/Per/60-1)*Per*60;
      k=iBarShift(NULL,Per,t,true); if (k < 0) continue; 
      i=iBars(NULL,Per);
      if (y==1) ArrayInitialize(TFLarge,0.0); else if (y==2) ArrayInitialize(TFMidle,0.0); else ArrayInitialize(TFSmall,0.0);
      NumberExt=0;
      for (x=k; x<i; x++) 
         {
         zz_Dn=iCustom( NULL, Per,"i_ZigZag_NK",Depth,Deviation,Backstep,0, x );
         if (zz_Dn !=0) 
            {
            NumberExt++;
            sh=iBarShift(NULL,CurPeriod,iTime(NULL,Per,x),false);
            limit=sh+Per/CurPeriod-1;            
            dn=iLowest(NULL,0,MODE_LOW,Per/CurPeriod,limit);
            if (y==1)ZZ_Large[dn]=Low[dn]; else if (y==2)ZZ_Midle[dn]=Low[dn]; else ZZ_Small[dn]=Low[dn];
            }
         zz_Up=iCustom( NULL, Per,"i_ZigZag_NK",Depth,Deviation,Backstep,1, x );
         if (zz_Up !=0) 
            {
            NumberExt++;
            sh=iBarShift(NULL,CurPeriod,iTime(NULL,Per,x),false);
            limit=sh+Per/CurPeriod-1;            
            up=iHighest(NULL,0,MODE_HIGH,Per/CurPeriod,limit);
            if (y==1)ZZ_Large[up]=High[up]; else if (y==2)ZZ_Midle[up]=High[up]; else ZZ_Small[up]=High[up];
            }
         //if (NumberExt>VolExt-1) break;
         }
      }
   PrevTimeZigZagCalc=Time[0]; // âû÷èñëèëè
   return;
}
//--------------------------------------------------------------------





Sample





Analysis



Market Information Used:


Series array that contains open time of each bar
Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_SECTION

Indicators Used:




Custom Indicators Used:
i_ZigZag_NK

Order Management characteristics:

Other Features: