//+------------------------------------------------------------------+ //| FigurelliSeries.mq5 | //| Copyright © 2010, Rogerio Figurelli | //| figurelli@quantafinance.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Rogerio Figurelli" #property link "http://www.quantafinance.com" //---- indicator version number #property version "1.00" //---- drawing indicator in a separate window #property indicator_separate_window //---- one buffer is used for calculation and drawing of the indicator #property indicator_buffers 1 //---- one plot is used #property indicator_plots 1 //+----------------------------------------------+ //| Indicator drawing parameters | //+----------------------------------------------+ //---- drawing the indicator as a histogram #property indicator_type1 DRAW_HISTOGRAM //---- DarkOrchid color is used as the color of the bullish line of the indicator #property indicator_color1 clrDarkOrchid //---- line of the indicator 1 is a continuous curve #property indicator_style1 STYLE_SOLID //---- indicator 1 line width is equal to 1 #property indicator_width1 1 //---- displaying of the bullish label of the indicator #property indicator_label1 "FigurelliSeries" //+----------------------------------------------+ //| Parameters of displaying horizontal levels | //+----------------------------------------------+ #property indicator_level1 0.0 #property indicator_levelcolor clrGray #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 uint StartPeriod=6; // initial period input uint Step=6; // periods calculation step input uint Total=36; // number of Moving Averages input ENUM_MA_METHOD MAType=MODE_EMA; // Moving Averages smoothing type input ENUM_APPLIED_PRICE MAPrice=PRICE_CLOSE; // price timeseries of Moving Averages input int Shift=0; // Horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of dynamic arrays that will further be // used as indicator buffers double IndBuffer[]; //---- Declaration of integer variables for the indicator handles int MA_Handle[]; //---- Declaration of integer variables of data starting point int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- Initialization of variables of data calculation starting point min_rates_total=int(StartPeriod+Step*(Total-1)); //---- memory allocation for array if(ArrayResize(MA_Handle,Total)rates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-1-min_rates_total; // starting index for the calculation of all bars } else limit=rates_total-prev_calculated; // starting index for the calculation of new bars //---- indexing elements in arrays as in timeseries ArraySetAsSeries(close,true); //---- main cycle of calculation of the indicator for(bar=limit; bar>=0 && !IsStopped(); bar--) { double tot_Ask=0; double tot_Bid=0; for(int count=0; countMA[0]) tot_Bid++; } IndBuffer[bar]=tot_Bid-tot_Ask; } //---- return(rates_total); } //+------------------------------------------------------------------+