Navigation´╝ÜHome > Content >

T3_double_bands.mq5

Time: 2018-01-20 | Download file:T3_double_bands.mq5

//+------------------------------------------------------------------+
//|                                              T3 double bands.mq5 |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "[email protected]"
#property version   "1.00"

//
//
//
//
//

#property indicator_chart_window
#property indicator_buffers 10
#property indicator_plots   5

#property indicator_label1  "Upper bands"
#property indicator_type1   DRAW_FILLING
#property indicator_color1  PowderBlue,MistyRose
#property indicator_label2  "Lower bands"
#property indicator_type2   DRAW_FILLING
#property indicator_color2  PowderBlue,MistyRose

#property indicator_label3  "High band"
#property indicator_type3   DRAW_COLOR_LINE
#property indicator_color3  SteelBlue,PaleVioletRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  2
#property indicator_label4  "Middle band"
#property indicator_type4   DRAW_COLOR_LINE
#property indicator_color4  SteelBlue,PaleVioletRed
#property indicator_style4  STYLE_SOLID
#property indicator_width4  2
#property indicator_label5  "Low band"
#property indicator_type5   DRAW_COLOR_LINE
#property indicator_color5  SteelBlue,PaleVioletRed
#property indicator_style5  STYLE_SOLID
#property indicator_width5  2

//
//
//
//
//

input int     T3Period        = 30;    // Calculation period
input double  T3Hot           = 0.7;   // T3 hot value
input bool    T3Original      = false; // T3 original Tillson calculation?
input bool    ShowLines       = true;  // Draw T3 lines?
input bool    MultiColorLines = true;  // Multi color mode for lines?
input bool    MultiColorBand  = true;  // Multi color mode for bands?

//
//
//
//
//
//

double UpFaBuffer[];
double UpFbBuffer[];
double DnFaBuffer[];
double DnFbBuffer[];
double UpBuffer[];
double UpColorBuffer[];
double MiBuffer[];
double MiColorBuffer[];
double DnBuffer[];
double DnColorBuffer[];
double trends[][5];
double c1,c2,c3,c4,t3Alpha;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int OnInit()
{
   SetIndexBuffer( 0,UpFaBuffer,INDICATOR_DATA);
   SetIndexBuffer( 1,UpFbBuffer,INDICATOR_DATA);
   SetIndexBuffer( 2,DnFaBuffer,INDICATOR_DATA);
   SetIndexBuffer( 3,DnFbBuffer,INDICATOR_DATA);
   SetIndexBuffer( 4,UpBuffer,INDICATOR_DATA);
   SetIndexBuffer( 5,UpColorBuffer,INDICATOR_COLOR_INDEX);
   SetIndexBuffer( 6,MiBuffer,INDICATOR_DATA);
   SetIndexBuffer( 7,MiColorBuffer,INDICATOR_COLOR_INDEX);
   SetIndexBuffer( 8,DnBuffer,INDICATOR_DATA);
   SetIndexBuffer( 9,DnColorBuffer,INDICATOR_COLOR_INDEX);

      if (ShowLines)
            for (int i=2; i<5; i++) PlotIndexSetInteger(i,PLOT_DRAW_TYPE,DRAW_COLOR_LINE);
      else  for (int i=2; i<5; i++) PlotIndexSetInteger(i,PLOT_DRAW_TYPE,DRAW_NONE);
      
   //
   //
   //
   //
   //
   
   double a  = MathMax(MathMin(T3Hot,1),0.0001);;
          c1 = -a*a*a;
          c2 =  3*(a*a+a*a*a);
          c3 = -3*(2*a*a+a+a*a*a);
          c4 = 1+3*a+a*a*a+3*a*a;
          double t3period  = T3Period; 
               if (!T3Original) t3period = 1.0 + (t3period-1.0)/2.0;
               t3Alpha = 2.0/(1.0 + t3period);
            
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &Time[],
                const double &Open[],
                const double &High[],
                const double &Low[],
                const double &Close[],
                const long &TickVolume[],
                const long &Volume[],
                const int &Spread[])
{
   if (ArrayRange(trends,0)!=rates_total) ArrayResize(trends,rates_total);

   //
   //
   //
   //
   //
      
      for (int i=(int)MathMax(prev_calculated-1,0); i0)
            {
               for (int k=0;k<5;k++) trends[i][k] = trends[i-1][k];

               if (UpBuffer[i]>UpBuffer[i-1])            trends[i][0] =  1;
               if (UpBuffer[i]MiBuffer[i-1])            trends[i][1] =  1;
               if (MiBuffer[i]DnBuffer[i-1])            trends[i][2] =  1;
               if (DnBuffer[i]        

Recommend