//+------------------------------------------------------------------+ //| ZigZag_NK_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 //--- two buffers are used for the indicator calculation and drawing #property indicator_buffers 2 //--- no graphical constructions #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 string levels_sirname="ZigZag_NK_Level"; // A name for the group of levels input uint SuprTotal=6; // The number of maxima and minima //--- input color Color_Res = clrLime; // Color of resistance input Style Style_Res = SOLID_; // Style of the maximum line input Width Width_Res = Width_3; // Width of the maximum line //--- input color Color_Sup = clrRed; // Color of support input Style Style_Sup = SOLID_; // Style of the minimum line input Width Width_Sup = Width_3; // Width of the minimum line //--- Zigzag parameters input uint ExtDepth=12; input uint ExtDeviation=5; input uint ExtBackstep=3; //+----------------------------------------------+ //--- declaring dynamic arrays that will be further used as the indicator buffers double HighestBuffer[],LowestBuffer[]; //--- declaration of strings 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=int(ExtDepth+ExtBackstep)*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,LowestBuffer)<=0) return(RESET); if(CopyBuffer(Ind_Handle,1,0,to_copy,HighestBuffer)<=0) return(RESET); //--- int upcount=0; int dncount=0; //--- main calculation loop of the indicator for(int bar=0; bar