//+------------------------------------------------------------------+ //| BandsFBA.mq5 | //| Copyright © 2010, Svinozavr | //| | //+------------------------------------------------------------------+ //---- author of the indicator #property copyright "Copyright © 2010, Svinozavr" //---- author of the indicator #property link "" //---- indicator version number #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- six buffers are used for calculation of drawing of the indicator #property indicator_buffers 6 //---- six graphical plots are used #property indicator_plots 6 //+--------------------------------------------+ //| BB levels indicator drawing parameters | //+--------------------------------------------+ //---- drawing Bollinger Bands as lines #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_LINE #property indicator_type5 DRAW_LINE #property indicator_type6 DRAW_LINE //---- selection of Bollinger Bands colors #property indicator_color1 clrPurple #property indicator_color2 clrPurple #property indicator_color3 clrPurple #property indicator_color4 clrRed #property indicator_color5 clrRed #property indicator_color6 clrRed //---- Bollinger Bands are dott-dash curves #property indicator_style1 STYLE_DASHDOTDOT #property indicator_style2 STYLE_DASHDOTDOT #property indicator_style3 STYLE_DASHDOTDOT //---- Bollinger Bands are continuous curves #property indicator_style4 STYLE_SOLID #property indicator_style5 STYLE_SOLID #property indicator_style6 STYLE_SOLID //---- Bollinger Bands width is equal to 1 #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 1 //+----------------------------------------------+ //| Averaging classes description | //+----------------------------------------------+ #include //+----------------------------------------------+ //---- declaration of the CXMA and CStdDeviation classes variables from the SmoothAlgorithms.mqh file CXMA XMA; CStdDeviation STD; //+----------------------------------------------+ //| declaration of enumerations | //+----------------------------------------------+ enum Applied_price_ //Type od constant { PRICE_CLOSE_ = 1, //Close PRICE_OPEN_, //Open PRICE_HIGH_, //High PRICE_LOW_, //Low PRICE_MEDIAN_, //Median Price (HL/2) PRICE_TYPICAL_, //Typical Price (HLC/3) PRICE_WEIGHTED_, //Weighted Close (HLCC/4) PRICE_SIMPL_, //Simpl Price (OC/2) PRICE_QUARTER_, //Quarted Price (HLOC/4) PRICE_TRENDFOLLOW0_, //TrendFollow_1 Price PRICE_TRENDFOLLOW1_ //TrendFollow_2 Price }; /*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 }; */ //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // The constant for returning the indicator recalculation command to the terminal //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input Smooth_Method bMA_Method=MODE_SMA; //first smoothing method input int bLength=20; //period of averaging of BB input int bPhase=15; //first 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 double BandsDeviation=2.0; //Bollinger deviation input Applied_price_ IPC=PRICE_CLOSE;//price constant /* , used for calculation of the indicator ( 1-CLOSE, 2-OPEN, 3-HIGH, 4-LOW, 5-MEDIAN, 6-TYPICAL, 7-WEIGHTED, 8-SIMPL, 9-QUARTER, 10-TRENDFOLLOW, 11-0.5 * TRENDFOLLOW.) */ input uint FrontPeriod=1; // front smoothing period; <1 input uint BackPeriod=55; // damping smoothing period; <1 input int BShift=0; // horizontal shift of the indicator in bars input int SShift=0; // horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of dynamic arrays that will further be // used as indicator buffers double XMAB[]; // XMA double TopB[]; // top line double BotB[]; // bottom line double XMAS[]; // top signal line double TopS[]; // top signal line double BotS[]; // bottom signal line //---- declaration of variables for the EMA coefficients double per0,per1; int FBA; // 1 - front smoothing, -1 - damping smoothing, 0 - normal MA - smooth all! //---- Declaration of integer variables of data starting point int min_rates_,min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- Initialization of variables of the start of data calculation string _fr=string(FrontPeriod); string _bk=string(BackPeriod); string _dv=string(BandsDeviation); string ShortName="BandsFBA"; string _sg=_fr; FBA=0; //---- front and damping if(FrontPeriod==BackPeriod) { FBA=0; per0=2.0/(1+FrontPeriod); per1=+1; } if(FrontPeriodrates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator { first=0; // starting number for calculation of all bars prev_stdevb=1.0; prev_stdevc=1.0; prev_xmab=PriceSeries(IPC,first,open,low,high,close); } else first=prev_calculated-1; // starting number for calculation of new bars //---- Main calculation loop of the indicator for(bar=first; bar1, then recalculated into EMA coefficient * int FBA +1 - front smoothing, * -1 - dumping smoothing, * 0 - normal EMA - smooth all! */ //+------------------------------------------------------------------+ double EMA_FBA(double Series,double EMA1,double period,int fba) { //---- if(period==1) return(Series); //---- coeff. EMA if(period>1) period=2.0/(1+period); //---- EMA double EMA=period*Series+(1-period)*EMA1; //---- separation of front and dumping switch(fba) { case 0: /* normal MA */ return(EMA); case 1: /* front smoothing */ if(Series>EMA1) return(EMA); else return(Series); case -1: /* dumping smoothing */ if(Series