//+------------------------------------------------------------------+ //| GannZIGZAG_Levels.mq5 | //| Copyright © 2014, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ //--- copyright #property copyright "Copyright © 2014, Nikolay Kositsin" //--- a link to the website of the author #property link "farria@mail.redcom.ru" //--- indicator version #property version "1.00" //--- drawing the indicator in the main window #property indicator_chart_window //--- one buffer is used for calculation and drawing of the indicator #property indicator_buffers 1 //--- 0 graphical plots are used #property indicator_plots 0 //+----------------------------------------------+ //| Declaration of enumeration | //+----------------------------------------------+ enum Width { Width_1=1, //1 Width_2, //2 Width_3, //3 Width_4, //4 Width_5 //5 }; //+----------------------------------------------+ //| Declaration of enumeration | //+----------------------------------------------+ enum Style { SOLID_, //Solid line DASH_, //Dashed line DOT_, //Dotted line DASHDOT_, //Dot-dash line DASHDOTDOT_ //Dot-dash line with double dots }; //+----------------------------------------------+ //| declaration of constants | //+----------------------------------------------+ #define RESET 0 // the constant for getting the command for the indicator recalculation back to the terminal //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Chart period input string levels_sirname="GannZIGZAG_Level"; // A name for the group of levels input uint SuprTotal=6; // The number of maxima and minima //--- input color Color_Res = clrSpringGreen; // Color of resistance input Style Style_Res = SOLID_; // The style of the maximum line input Width Width_Res = Width_3; // The width of the maximum line //--- input color Color_Sup = clrMagenta; // Color of support input Style Style_Sup = SOLID_; // The style of the minimum line input Width Width_Sup = Width_3; // The width of the minimum line //--- zigzag parameters input uint GSv_range=2; //+----------------------------------------------+ //--- declaring dynamic arrays that will be further used as the indicator buffers double ZigzagBuffer[]; //--- declaring string variables for storing the names of the lines string UpLinesName[],DnLinesName[]; //--- declaration of integer variables for the start of data calculation int min_rates_total,nSuprTotal; //--- declaration of integer variables for the indicators handles int Ind_Handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- memory distribution for variables' arrays ArrayResize(UpLinesName,SuprTotal); ArrayResize(DnLinesName,SuprTotal); //--- initialization of global variables nSuprTotal=int(SuprTotal); min_rates_total=2*nSuprTotal*2; for(int count=0; countrates_total || prev_calculated<=0)// checking for the first start of calculation of an indicator limit=rates_total-2; // Starting index for the calculation of all bars else limit=rates_total-prev_calculated; // starting index for the calculation of new bars int to_copy=limit+1; //--- copy newly appeared data in the arrays if(CopyBuffer(Ind_Handle,0,0,to_copy,ZigzagBuffer)<=0) return(RESET); //--- int upcount=0; int dncount=0; //--- main calculation loop of the indicator for(int bar=0; bar