//+------------------------------------------------------------------+ //| SumXMA.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 the indicator in the main window #property indicator_chart_window //---- one buffer is used for calculation and drawing of the indicator #property indicator_buffers 1 //---- one plot is used #property indicator_plots 1 //+----------------------------------------------+ //| Cycle indicator drawing parameters | //+----------------------------------------------+ //---- drawing indicator 1 as a line #property indicator_type1 DRAW_LINE //---- SlateBlue color is used as the color of the bullish line of the indicator #property indicator_color1 clrSlateBlue //---- 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 "SumXMA" //+----------------------------------------------+ //| CXMA class description | //+----------------------------------------------+ #include //+----------------------------------------------+ //---- declaration of the CXMA class variables from the SmoothAlgorithms.mqh file CXMA XMA[]; //+----------------------------------------------+ //| declaration of enumerations | //+----------------------------------------------+ /*enum Smooth_Method - enumeration is declared in SmoothAlgorithms.mqh { MODE_SMA_, //SMA MODE_EMA_, //EMA MODE_SMMA_, //SMMA MODE_LWMA_, //LWMA MODE_JJMA, //JJMA MODE_JurX, //JurX MODE_ParMA, //ParMA MODE_T3, //T3 MODE_VIDYA, //VIDYA MODE_AMA, //AMA }; */ //+----------------------------------------------+ //| INDICATOR INPUT PARAMETERS | //+----------------------------------------------+ input Smooth_Method XMA_Method=MODE_SMA; //smoothing method input uint StartLength=20; //initial smoothing period input uint EndLength=100; //final smoothing period input int XPhase=15; //smoothing parameter, // for JJMA that can change withing the range -100 ... +100. It impacts the quality of the intermediate process of smoothing; // For VIDIA, it is a CMO period, for AMA, it is a slow moving average 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 SumXMABuffer[]; bool Init; //---- Declaration of integer variables of data starting point int min_rates_total,xSize; //---- Declaration of the average vertical shift value variable double dPriceShift; //+------------------------------------------------------------------+ //| 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(XMA,xSize)rates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-1-begin; // starting index for calculation of all bars //---- shifting the starting point for drawing indicator by min_rates_total+begin PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total+begin); } else limit=rates_total-prev_calculated; // starting index for the calculation of new bars MaxBar=rates_total-min_rates_total-1-begin; //---- indexing elements in arrays as timeseries ArraySetAsSeries(price,true); //---- main indicator calculation loop for(bar=limit; bar>=0 && !IsStopped(); bar--) { Sum=0.0; for(int number=0; number