Просьба добавить временные рамки в индикатор

 
//+------------------------------------------------------------------+
//|                                                      Э В А-1.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//V// ЭВА-1
#property indicator_separate_window
#property indicator_buffers    8
#property indicator_color8     DarkOliveGreen
#property indicator_color7     Magenta
#property indicator_color6     Blue
#property indicator_color5     Magenta
#property indicator_color4     Teal //Линия
#property indicator_levelcolor Green
#property indicator_style1     STYLE_DOT
#property indicator_style2     STYLE_DOT
#property  indicator_level1    0
//V// ЭВА
#property indicator_minimum -0.007
#property indicator_maximum  0.007
#property indicator_color3 Black
#property indicator_color2 Lime
#property indicator_color1 Red
//#property  indicator_levelcolor Green
//#property  indicator_level1 0

//
extern string A1 = "------------- ЭВА-1 ------------";
extern int  Length               = 14;
extern int  Price                = 0;
extern bool Double               = false;
extern bool ShowHistogram        = true;
extern bool ShowUpDownLimit      = false;
extern bool PreFilterPrice       = true;
extern int  PreFilterPriceLength = 4;
extern double Kot = 0.0001; //0.001
extern string A2 = "------------- ЭВА ------------";
extern int period = 12;
//
// ЭВА-1
double rsx[];
double rsxU[];
double rsxD[];
double limU[];
double limD[];
double stored[][26];

int    Correction = 0;
int    LoopCount  = 1;
double smoothCoeffs[];
double smoothDivisor;
#define Pi 3.141592653589793238462643
//ЭВА
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
string gs_92 = "";
string gs_100;

int init()
{
   SetIndexBuffer(7,limU); SetIndexLabel(7,NULL);
   SetIndexBuffer(6,limD); SetIndexLabel(6,NULL);
   SetIndexBuffer(3,rsx);  SetIndexLabel(3,"RSX4");
   if (ShowHistogram)
   {
      SetIndexBuffer(5,rsxU); SetIndexStyle(5,DRAW_HISTOGRAM); SetIndexLabel(5,"RSX2");
      SetIndexBuffer(4,rsxD); SetIndexStyle(4,DRAW_HISTOGRAM); SetIndexLabel(4,"RSX3");
      Correction = -50;
   }
   else
   {
      SetIndexStyle(5,DRAW_NONE); SetIndexLabel(5,NULL);
      SetIndexStyle(4,DRAW_NONE); SetIndexLabel(4,NULL);
   }
   if (Double) LoopCount = 2;
   //V //ЭВА
   SetIndexStyle(2, DRAW_NONE, STYLE_SOLID, 0);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 0);
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 0);
   IndicatorDigits(Digits + 1);
   SetIndexBuffer(2, g_ibuf_80);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexBuffer(0, g_ibuf_88);
   
   SetIndexLabel(1, "ЭВА");
   SetIndexLabel(0, "ЭВА");
   
   //V  //ЭВА-1 
   ArrayResize(smoothCoeffs, PreFilterPriceLength);
      smoothCoeffs[0] = 1;
      smoothDivisor   = 1;
      for (int i = 1; i < PreFilterPriceLength; i++)
      {
         double temp = 1 << i / Pi;
            smoothCoeffs[i] = MathSin(temp) / temp;
            smoothDivisor  += smoothCoeffs[i];
      }

   //    
//   IndicatorShortName("Э_В_А("+period+") + Э_В_А-1("+Length+")");
   gs_100 = "Э В А("+period+") + Э В А-1("+Length+")";
   IndicatorShortName(gs_100);
   creataalltext();
   return(0);
}
int deinit() { ObjectDelete(gs_100);  return(0); }

//

int start()
{
   
   //V //ЭВА
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_48 = 0;
   double ld_56 = 0;
   double ld_80 = 0;
   double l_low_96 = 0;
   double l_high_104 = 0;
   int li_112 = 16777215;
   //
   int i,r,limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit = Bars-counted_bars;
   
   if (ArrayRange(stored,0) != Bars) ArrayResize(stored,Bars);
   //V //ЭВА 
   for (i = 0; i < limit; i++) {
      l_high_104 = High[iHighest(NULL, 0, MODE_HIGH, period, i)];
      l_low_96 = Low[iLowest(NULL, 0, MODE_LOW, period, i)];
      ld_16 = (High[i] + Low[i]) / 2.0;
      ld_48 = 0.66 * ((ld_16 - l_low_96) / (l_high_104 - l_low_96) - 0.5) + 0.67 * ld_56;
      ld_48 = MathMin(MathMax(ld_48, -0.999), 0.999);
      g_ibuf_80[i] = MathLog((ld_48 + 1.0) / (1 - ld_48)) / 2.0 + ld_80 / 2.0;
      ld_56 = ld_48;
      ld_80 = g_ibuf_80[i];
   }
   bool li_124 = TRUE;
   // 

   for(i=limit, r=Bars-i-1; i>=0; i--, r++)
   {
      //"------------- ЭВА ------------"
      ld_8 = g_ibuf_80[i];
      ld_0 = g_ibuf_80[i + 1];
      if ((ld_8 < 0.0 && ld_0 > 0.0) || ld_8 < 0.0) li_124 = FALSE;
      if ((ld_8 > 0.0 && ld_0 < 0.0) || ld_8 > 0.0) li_124 = TRUE;
      if (!li_124) {
         g_ibuf_88[i] = ld_8;
         g_ibuf_84[i] = EMPTY_VALUE;
         gs_92 = "Медвежье поглощение - ПРОДАВАТЬ! ";
         li_112 = Magenta;
      } else {
         g_ibuf_84[i] = ld_8;
         g_ibuf_88[i] = EMPTY_VALUE;
         gs_92 = "Бычье поглощение -  ПОКУПАТЬ! ";
         li_112 = LawnGreen;
      }

      //"------------- ЭВА-1 ------------"
      if (!PreFilterPrice) double trsx = iMA(NULL,0,1,0,MODE_SMA,Price,i);
      else  
         {
            double sum = 0;
            for (int l = 0; l < PreFilterPriceLength; l++) sum += iMA(NULL,0,1,0,MODE_SMA,Price,l+i)*smoothCoeffs[l];
                  trsx = (sum/smoothDivisor);
         }                  
      
      //

      for (int k=0; k<LoopCount; k++)
      {
         stored[r][24+k] = trsx;
            double roc   = trsx-stored[r-1][24+k];
            double roa   = MathAbs(roc);
            double avg1  = iCalc(roc,Length,i,r,k*12);
            double avg2  = iCalc(roa,Length,i,r,k*12+6);

            //

               
            if (avg2 != 0)
                 trsx = MathMax(MathMin((avg1/avg2+1.0)*50.0,100.00),0.00); 
            else trsx = 50.0;
      }            
      rsx[i] = (trsx+Correction)*Kot;

      //
               
      if (ShowHistogram)
      {
         rsxD[i] = rsxD[i+1];
         rsxU[i] = rsxU[i+1];
            if (rsx[i] > rsx[i+1]) { rsxU[i] = rsx[i];  rsxD[i] = EMPTY_VALUE; }
            if (rsx[i] < rsx[i+1]) { rsxD[i] = rsx[i];  rsxU[i] = EMPTY_VALUE; }
      }
      if (ShowUpDownLimit)
      {
         limD[i] = Correction*Kot;
         limU[i] = (Correction+100)*Kot;
      } 
              
   }     
   //
   settext("Э_В_Аm", gs_92, 12, li_112, 10, 15);     
   return(0);
}






#define F01 0
#define F02 1
#define F03 2
#define F04 3
#define F05 4
#define F06 5

//

double iCalc(double price, int period, int i, int r, int s)
{
   double f01=stored[r-1][s+F01];  double f02=stored[r-1][s+F02];
   double f03=stored[r-1][s+F03];  double f04=stored[r-1][s+F04];
   double f05=stored[r-1][s+F05];  double f06=stored[r-1][s+F06];

   //
      double Kg = 3.0/(2.0+period);
      double Hg = 1.0-Kg;

      f01 = Kg * price + Hg * f01; f02 = Kg * f01 + Hg * f02; double v01 = 1.5 * f01 - 0.5 * f02;
      f03 = Kg * v01   + Hg * f03; f04 = Kg * f03 + Hg * f04; double v02 = 1.5 * f03 - 0.5 * f04;
      f05 = Kg * v02   + Hg * f05; f06 = Kg * f05 + Hg * f06; double v03 = 1.5 * f05 - 0.5 * f06;

   //
   stored[r][s+F01] = f01;  stored[r][s+F02] = f02;
   stored[r][s+F03] = f03;  stored[r][s+F04] = f04;
   stored[r][s+F05] = f05;  stored[r][s+F06] = f06;
   return(v03);
}

void creataalltext() {
   ObjectCreate("Э_В_Аm", OBJ_LABEL, WindowFind(WindowExpertName( )), 0, 0);
   settext("Э_В_Аm", "", 12, White, 10, 15);
}
void settext(string a_name_0, string a_text_8, int a_fontsize_16, color a_color_20, int a_x_24, int a_y_28) {
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_24);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_28);
   ObjectSetText(a_name_0, a_text_8, a_fontsize_16, "Arial", a_color_20);
}
Файлы:
aorwud1x2.mq4  8 kb