//+------------------------------------------------------------------+
//|                                                   i-DayRange.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|   17.11.2005  Èíäèêàòîð äíåâíîãî äèàïàçîíà                       |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_color3 Red
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int NumberOfDays = 365;   // Êîëè÷åñòâî äíåé (0-âñå)
double shifthigh[];
double shiftlow[];
double shiftaver[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() {
  SetIndexStyle(0,DRAW_LINE, 0,1);
  SetIndexBuffer(0,shifthigh);
  SetIndexLabel(0,"Up Channel");
  SetIndexDrawBegin(0,0);
  SetIndexStyle(1,DRAW_LINE, 0,1);
  SetIndexBuffer(1,shiftlow);
  SetIndexLabel(1,"Down Channel");
  SetIndexDrawBegin(1,0);
  SetIndexStyle(2,DRAW_LINE, 0,1);
  SetIndexBuffer(2,shiftaver);
  SetIndexLabel(2,"Average Channel");
  SetIndexDrawBegin(2,0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+ 
void start() {
  double LowLine=0;
  double HighLine=0;
  double AverLine=0;
  for (int i=NumberBar(); i>0; i--) {
    if (TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) {
      LowLine=iLow(Symbol(),0,i);
      HighLine=iHigh(Symbol(),0,i);
    } else {
      if (iLow(Symbol(),0,i)<LowLine) LowLine=iLow(Symbol(),0,i);
      if (iHigh(Symbol(),0,i)>HighLine) HighLine=iHigh(Symbol(),0,i);
    }
    AverLine=LowLine+(HighLine-LowLine)/2;
    shiftlow[i]=LowLine;
    shifthigh[i]=HighLine;
    shiftaver[i]=AverLine;
  }
  Comment("Òåêóùèé äíåâíîé äèàïàçîí: "+DoubleToStr((HighLine-LowLine)/Point,0)+" ï.");
}
//+------------------------------------------------------------------+ 
//| Âîçâðàùàåò íîìåð áàðà                                            |
//+------------------------------------------------------------------+ 
int NumberBar() {
  int nd=0, i=0;
  while (nd<NumberOfDays) {
    i++;
    if (TimeHour(Time[i])==0 && TimeMinute(Time[i])==0) nd++;
  }
  return(i);
}
//+------------------------------------------------------------------+
--------------080900020905040503000501--
Comments