//+------------------------------------------------------------------+ //| StepMA_Stoch_KV1_HTF.mq5 | //| Copyright © 2014, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2014, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- Indicator version number #property version "1.60" //---- drawing indicator in a separate window #property indicator_separate_window //---- number of indicator buffers 2 #property indicator_buffers 2 //---- only one plot is used #property indicator_plots 1 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //---- drawing the indicator as a seven-color histogram #property indicator_type1 DRAW_COLOR_HISTOGRAM //---- colors of the seven-color histogram are as follows #property indicator_color1 clrMagenta,clrMediumVioletRed,clrPlum,clrGray,clrLightSkyBlue,clrTeal,clrDodgerBlue //---- Indicator line is a solid one #property indicator_style1 STYLE_SOLID //---- indicator line width is 2 #property indicator_width1 2 //---- displaying the indicator label #property indicator_label1 "StepMA_Stoch_KV1 HTF" //+-----------------------------------+ //| Declaration of constants | //+-----------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal //+-----------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-----------------------------------+ input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4;//Chart period input bool ReDraw=true; //repeat information display on empty bars input uint PeriodWATR=10; input double Kwatr=1.0000; input bool HighLow=false; //+-----------------------------------+ //---- Declaration of integer variables of data starting point int min_rates_total; //---- Declaration of integer variables for the indicator handles int Ind_Handle; //---- declaration of dynamic arrays that // will be used as indicator buffers double IndBuffer[],ColorIndBuffer[]; //+------------------------------------------------------------------+ //| Getting string timeframe | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of the start of data calculation min_rates_total=3; //---- Checking correctness of the chart periods if(TimeFramerates_total || prev_calculated<=0)// checking for the first start of calculation of an indicator { limit=rates_total-min_rates_total-1; // starting index for the calculation of all bars LastCountBar=rates_total; } else limit=int(LastCountBar)+rates_total-prev_calculated; // starting index for the calculation of new bars //---- indexing elements in arrays as in timeseries ArraySetAsSeries(time,true); //---- Main calculation loop of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { //---- Zero out the contents of the indicator buffers for the calculation IndBuffer[bar]=EMPTY_VALUE; ColorIndBuffer[bar]=0; //---- Copy the new data into the array if(CopyTime(Symbol(),TimeFrame,time[bar],1,IndTime)<=0) return(RESET); if(time[bar]>=IndTime[0] && time[bar+1]