//+------------------------------------------------------------------+ //| AFIRMA.mq5 | //| | //| Copyright © 2006, gpwr. | //+------------------------------------------------------------------+ //---- author of the indicator #property copyright "Copyright © 2006, gpwr." #property link "" //---- indicator version #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- two buffers are used for calculation and drawing the indicator #property indicator_buffers 2 //---- only two plots are used #property indicator_plots 2 //+----------------------------------------------+ //| Declaration of constants | //+----------------------------------------------+ #define RESET 0 #define pi 3.141592653589793238462643383279502884197169399375105820974944592 //+----------------------------------------------+ //| Indicator 1 drawing parameters | //+----------------------------------------------+ //---- drawing indicator 1 as a line #property indicator_type1 DRAW_LINE //---- use blue violet color for the indicator 1 line #property indicator_color1 BlueViolet //---- line of the indicator 1 is a continuous line #property indicator_style1 STYLE_SOLID //---- indicator 1 line width is equal to 2 #property indicator_width1 2 //---- displaying the indicator line label #property indicator_label1 "FIRMA" //+----------------------------------------------+ //| Indicator 2 drawing parameters | //+----------------------------------------------+ //---- drawing the indicator 2 as a line #property indicator_type2 DRAW_LINE //---- red color is used for the indicator 2 line #property indicator_color2 Red //---- the indicator 2 line is a continuous curve #property indicator_style2 STYLE_SOLID //---- indicator 2 line width is equal to 2 #property indicator_width2 2 //---- displaying the indicator line label #property indicator_label2 "ARMA" //+----------------------------------------------+ //| Declaration of enumerations | //+----------------------------------------------+ enum ENUM_WINDOWS // Type of constant { Rectangular = 1, // Rectangular window Hanning1, // Hanning window 1 Hanning2, // Hanning window 2 Blackman, // Blackman window Blackman_Harris // Blackman-Harris window }; //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input int Periods = 4; // LF transmission width 1/(2*Periods) input int Taps = 21; // Number of delay units in the filter input ENUM_WINDOWS Window=Blackman; // Window index input int Shift=0; // Horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of the integer variables for the start of data calculation int min_rates_total; //---- declaration of global variables int n; double w[],wsum,sx2,sx3,sx4,sx5,sx6,den; //---- declaration of dynamic arrays that //---- will be used as indicator buffers double FIRMABuffer[],ARMABuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- initialization of variables ArrayResize(w,Taps); wsum=0.0; for(int k=0; krates_total || prev_calculated<=0)// checking for the first start of the indicator calculation { limit=rates_total-1-min_rates_total-begin; // starting index for calculation of all bars //---- performing the shift of the beginning of the indicators drawing PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total+begin); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total+begin); } else limit=rates_total-prev_calculated; // starting index for calculation of new bars //---- indexing elements in arrays as timeseries ArraySetAsSeries(price,true); //---- main cycle of calculation of FIRMA indicator for(bar=limit; bar>=0; bar--) { FIRMABuffer[bar+n]=0.0; for(int k=0; k=0; bar--) { if(bar