//+------------------------------------------------------------------+ //| SumRSI.mq5 | //| Copyright © 2008, jax1000 | //| jax1000@list.ru | //+------------------------------------------------------------------+ //---- author of the indicator #property copyright "Copyright © 2008, jax1000" //---- author of the indicator #property link "jax1000@list.ru" //---- 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 //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // The constant for getting the command for the indicator recalculation back to the terminal //+----------------------------------------------+ //| SumRSI indicator drawing parameters | //+----------------------------------------------+ //---- drawing indicator 1 as a line #property indicator_type1 DRAW_LINE //---- DarkOrange color is used as the color of the bullish line of the indicator #property indicator_color1 clrDarkOrange //---- line of the indicator 1 is a continuous curve #property indicator_style1 STYLE_SOLID //---- thickness of line of the indicator 1 is equal to 3 #property indicator_width1 3 //---- displaying of the bullish label of the indicator #property indicator_label1 "SumRSI" //+----------------------------------------------+ //| Parameters of displaying horizontal levels | //+----------------------------------------------+ #property indicator_level1 70.0 #property indicator_level2 50.0 #property indicator_level3 30.0 #property indicator_levelcolor clrBlue #property indicator_levelstyle STYLE_DASHDOTDOT //+----------------------------------------------+ //| Window borders fixing parameters | //+----------------------------------------------+ #property indicator_minimum 0 #property indicator_maximum 100 //+----------------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+----------------------------------------------+ input uint StartLength=3; // initial smoothing period input uint EndLength=25; // final smoothing period input ENUM_APPLIED_PRICE Applied_Price=PRICE_CLOSE; // type of price input int Shift=0; // horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of dynamic arrays that will further be // used as indicator buffers double SumRSIBuffer[]; //---- bool Init; //---- declaration of integer variables for the indicators handles int RSI_Handle[]; //---- Declaration of integer variables of data starting point int min_rates_total,xSize; //+------------------------------------------------------------------+ //| Arrays of variables | //+------------------------------------------------------------------+ class CRSI { public: double m_RSI[]; }; //+------------------------------------------------------------------+ //| Create arrays with two dimensions | //+------------------------------------------------------------------+ CRSI RSI[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- setting alerts for invalid values of external parameters if(StartLength>EndLength) { Init=false; Print("The initial period of the indicator can not be greater than the final period!"); return; } //---- memory allocation for arrays of variables xSize=int(EndLength-StartLength+1); if(ArrayResize(RSI_Handle,xSize)rates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-1; // starting index for the calculation of all bars } else limit=rates_total-prev_calculated; // starting index for the calculation of new bars to_copy=limit+1; //---- copy the newly appeared data into the RSI[count].m_RSI[] arrays for(int count=0; count=0 && !IsStopped(); bar--) { Sum=0.0; for(int count=0; count