#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

string gs_unused_76 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string gs_unused_84 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string gs_unused_92 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string gs_unused_100 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string gs_unused_108 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string gs_unused_116 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string gs_unused_124 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string gs_unused_132 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string gs_unused_140 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";
extern int ChannelPeriod = 14;
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
string gs_unused_164 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string gs_unused_172 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string gs_unused_180 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string gs_unused_188 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string gs_unused_196 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string gs_unused_204 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string gs_unused_212 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string gs_unused_220 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string gs_unused_228 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_152);
   SetIndexBuffer(1, g_ibuf_156);
   SetIndexBuffer(2, g_ibuf_160);
   string ls_0 = "Channel(" + ChannelPeriod + ")";
   IndicatorShortName(ls_0);
   SetIndexLabel(0, "UpCh");
   SetIndexLabel(1, "DownCh");
   SetIndexLabel(2, "MidCh");
   SetIndexDrawBegin(0, ChannelPeriod);
   SetIndexDrawBegin(1, ChannelPeriod);
   SetIndexDrawBegin(2, ChannelPeriod);
   return (0);
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   int l_ind_counted_24 = IndicatorCounted();
   if (Bars <= ChannelPeriod) return (0);
   if (l_ind_counted_24 < 1) for (int li_28 = 1; li_28 <= ChannelPeriod; li_28++) g_ibuf_152[Bars - li_28] = 0.0;
   li_28 = Bars - ChannelPeriod - 1;
   if (l_ind_counted_24 >= ChannelPeriod) li_28 = Bars - l_ind_counted_24 - 1;
   while (li_28 >= 0) {
      ld_0 = High[li_28];
      ld_8 = Low[li_28];
      for (int li_32 = li_28 - 1 + ChannelPeriod; li_32 >= li_28; li_32--) {
         ld_16 = High[li_32];
         if (ld_0 < ld_16) ld_0 = ld_16;
         ld_16 = Low[li_32];
         if (ld_8 > ld_16) ld_8 = ld_16;
      }
      g_ibuf_152[li_28] = ld_0;
      g_ibuf_156[li_28] = ld_8;
      g_ibuf_160[li_28] = (ld_0 + ld_8) / 2.0;
      li_28--;
   }
   return (0);
}