/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  H T T p :/ / Ww w . m ET a Q Uo Te S. n e T
   E-mail :  s u p PorT@M E T AqU o tE s . NE T
*/
#property copyright "Copyright © 2009, CompassFX"
#property link      "http://www.compassfx.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 DodgerBlue
#property indicator_color3 Red
#property indicator_color4 DodgerBlue

extern string Custom_Indicator = "Synergy Average Price Bars";
extern string Copyright = "© 2009, CompassFX";
extern string Web_Address = "www.compassfx.com";
double G_ibuf_100[];
double G_ibuf_104[];
double G_ibuf_108[];
double G_ibuf_112[];
int Gi_116 = 0;

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Red);
   SetIndexBuffer(0, G_ibuf_100);
   SetIndexLabel(0, "HA_0");
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1, DodgerBlue);
   SetIndexBuffer(1, G_ibuf_104);
   SetIndexLabel(1, "HA_1");
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red);
   SetIndexBuffer(2, G_ibuf_108);
   SetIndexLabel(2, "HA_Open");
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, DodgerBlue);
   SetIndexBuffer(3, G_ibuf_112);
   SetIndexLabel(3, "HA_Close");
   SetIndexDrawBegin(0, 10);
   SetIndexDrawBegin(1, 10);
   SetIndexDrawBegin(2, 10);
   SetIndexDrawBegin(3, 10);
   SetIndexBuffer(0, G_ibuf_100);
   SetIndexBuffer(1, G_ibuf_104);
   SetIndexBuffer(2, G_ibuf_108);
   SetIndexBuffer(3, G_ibuf_112);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double Ld_0;
   double Ld_8;
   double Ld_16;
   double Ld_24;
   if (Bars <= 10) return (0);
   Gi_116 = IndicatorCounted();
   if (Gi_116 < 0) return (-1);
   if (Gi_116 > 0) Gi_116--;
   for (int Li_32 = Bars - Gi_116 - 1; Li_32 >= 0; Li_32--) {
      Ld_24 = NormalizeDouble((Open[Li_32] + High[Li_32] + Low[Li_32] + Close[Li_32]) / 4.0, Digits);
      Ld_24 = (Ld_24 + Close[Li_32]) / 2.0;
      Ld_0 = (G_ibuf_108[Li_32 + 1] + (G_ibuf_112[Li_32 + 1])) / 2.0;
      Ld_8 = MathMax(High[Li_32], MathMax(Ld_0, Ld_24));
      Ld_16 = MathMin(Low[Li_32], MathMin(Ld_0, Ld_24));
      if (Ld_0 < Ld_24) {
         G_ibuf_100[Li_32] = Ld_16;
         G_ibuf_104[Li_32] = Ld_8;
      } else {
         G_ibuf_100[Li_32] = Ld_8;
         G_ibuf_104[Li_32] = Ld_16;
      }
      G_ibuf_108[Li_32] = Ld_0;
      G_ibuf_112[Li_32] = Ld_24;
   }
   return (0);
}
