//+------------------------------------------------------------------+ //| AroonOscillator_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 #property version "1.60" //--- drawing the indicator in a separate window #property indicator_separate_window //--- number of indicator buffers is 2 #property indicator_buffers 2 //--- one plot is used #property indicator_plots 1 //+----------------------------------------------+ //| Indicator drawing parameters | //+----------------------------------------------+ //--- drawing the indicator as a four-color histogram #property indicator_type1 DRAW_COLOR_HISTOGRAM //--- colors of the four-color histogram are as follows #property indicator_color1 clrRed,clrMediumVioletRed,clrGray,clrTeal,clrLime //--- Indicator line is a solid one #property indicator_style1 STYLE_SOLID //--- indicator line width is 5 #property indicator_width1 5 //--- displaying the indicator label #property indicator_label1 "Aroon Oscillator HTF" //+----------------------------------------------+ //| Parameters of displaying horizontal levels | //+----------------------------------------------+ #property indicator_level1 +50 #property indicator_level2 0 #property indicator_level3 -50 #property indicator_levelcolor clrBlue #property indicator_levelstyle STYLE_DASHDOTDOT //+----------------------------------------------+ //| 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 uint AroonPeriod=9; // Indicator period input bool ReDraw=true; // repeat information display on empty bars //+----------------------------------------------+ //--- declaration of a variable for storing the indicator initialization result bool Init; //--- declaration of integer variables of data starting point int min_rates_total; //--- declaration of integer variables for the indicators handles int Ind_Handle; //--- declaration of dynamic arrays that //--- will be used as indicator buffers double IndBuffer[],ColorIndBuffer[]; //+------------------------------------------------------------------+ //| Getting a timeframe as a line | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) {return(StringSubstr(EnumToString(timeframe),7,-1));} //+------------------------------------------------------------------+ //| Aroon oscillator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- initialization of variables of the start of data calculation min_rates_total=3; Init=true; //--- 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 //--- apply timeseries indexing to array elements 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]=2; //--- copy newly appeared data in the array if(CopyTime(Symbol(),TimeFrame,time[bar],1,IndTime)<=0) return(RESET); //--- if(time[bar]>=IndTime[0] && time[bar+1]0) { if(Ind[1]>Ind[0]) clr=4; if(Ind[1]Ind[0]) clr=1; } ColorIndBuffer[bar]=clr; } //--- if(ReDraw) { if(IndBuffer[bar+1]!=EMPTY_VALUE && IndBuffer[bar]==EMPTY_VALUE) { IndBuffer[bar]=IndBuffer[bar+1]; ColorIndBuffer[bar]=ColorIndBuffer[bar+1]; } } } //--- return(rates_total); } //+------------------------------------------------------------------+