#property copyright "Copyright © 2007, CompassFX,LLC."
#property link      "www.compassfx.com"

#property indicator_separate_window
#property indicator_minimum -0.1
#property indicator_maximum 1.3
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green

extern string Custom_Indicator = "Continuation";
extern string Copyright = "© 2007, CompassFX,LLC.";
extern string Web_Address = "www.compassfx.com";
extern string MA_Method_Help = "SMA=0, EMA=1";
extern int MA_Method = 0;
extern double MA_Period = 2.0;
double G_ibuf_120[];
double G_ibuf_124[];
double G_ibuf_128[];
double G_ibuf_132[];
int Gi_136 = 0;

int init() {
   IndicatorShortName("Continuation | www.compassfx.com  ");
   IndicatorBuffers(4);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(0, G_ibuf_120);
   SetIndexBuffer(1, G_ibuf_124);
   SetIndexBuffer(2, G_ibuf_128);
   SetIndexBuffer(3, G_ibuf_132);
   SetIndexLabel(0, "Cont_Down");
   SetIndexLabel(1, "Cont_Up");
   SetIndexDrawBegin(0, 10);
   SetIndexDrawBegin(1, 10);
   return (0);
}

int start() {
   double Ld_0;
   double Ld_8;
   double Ld_16;
   double Ld_24;
   double Ld_32;
   double Ld_40;
   double Ld_48;
   double Ld_56;
   if (Bars <= 10) return (0);
   Gi_136 = IndicatorCounted();
   if (Gi_136 < 0) return (-1);
   if (Gi_136 > 0) Gi_136--;
   for (int Li_64 = Bars - Gi_136 - 1; Li_64 >= 0; Li_64--) {
      Ld_0 = NormalizeDouble(iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_CLOSE, Li_64), Digits);
      Ld_8 = NormalizeDouble(iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_LOW, Li_64), Digits);
      Ld_16 = NormalizeDouble(iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_OPEN, Li_64), Digits);
      Ld_24 = NormalizeDouble(iMA(NULL, 0, MA_Period, 0, MA_Method, PRICE_HIGH, Li_64), Digits);
      Ld_32 = NormalizeDouble((G_ibuf_128[Li_64 + 1] + (G_ibuf_132[Li_64 + 1])) / 2.0, Digits);
      Ld_56 = NormalizeDouble((Ld_0 + Ld_24 + Ld_16 + Ld_8) / 4.0, Digits);
      Ld_40 = MathMax(Ld_24, MathMax(Ld_32, Ld_56));
      Ld_48 = MathMin(Ld_16, MathMin(Ld_32, Ld_56));
      if (Ld_32 < Ld_56) {
         G_ibuf_120[Li_64] = 0;
         G_ibuf_124[Li_64] = 1;
      } else {
         G_ibuf_120[Li_64] = 1;
         G_ibuf_124[Li_64] = 0;
      }
      G_ibuf_128[Li_64] = Ld_32;
      G_ibuf_132[Li_64] = Ld_56;
   }
   return (0);
}
