//+------------------------------------------------------------------+ //| iClose_HTF.mq5 | //| Copyright © 2010, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- indicator version number #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers is 1 #property indicator_buffers 1 //---- only one plot is used #property indicator_plots 1 //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal #define INDICATOR_NAME "iClose" // The constant for the name of the indicator //+----------------------------------------------+ //| Indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 1 as a symbol #property indicator_type1 DRAW_SECTION //---- the following colors are used as the indicator colors #property indicator_color1 clrMagenta //---- indicator 1 line width is 1 #property indicator_width1 1 //---- displaying the indicator label #property indicator_label1 INDICATOR_NAME //+-------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-------------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4;//Chart period input int Shift=0; // horizontal shift of the indicator in bars input int PriceShift=0; // vertical shift of the indicator in points //+-------------------------------------+ //---- declaration of dynamic arrays that will further be // used as indicator buffers double IndBuffer[],ColorIndBuffer[]; //---- Declaration of a variable for storing the indicator initialization result bool Init; double dPriceShift; //---- Declaration of strings string Symbol_,Word; //---- Declaration of integer variables of data starting point int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { Init=true; //---- checking the chart periods for correctness if(TimeFramerates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-2; // starting index for the calculation of all bars LastCountBar=limit; } else limit=int(LastCountBar)+rates_total-prev_calculated; // starting index for the calculation of new bars //---- indexing array elements as time series ArraySetAsSeries(time,true); ArraySetAsSeries(close,true); //---- main indicator calculation loop for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- zero out the contents of the indicator buffers for the calculation IndBuffer[bar+1]=0.0; //---- copy new data to the iTime array if(CopyTime(Symbol_,TimeFrame,time[bar],1,iTime)<=0) return(RESET); if(time[bar]>=iTime[0] && time[bar+1]