/*
   Generated by EX4-TO-MQ4 decompiler ONE FILE V4.0.217.1
   EX4 ID : 1BA037F9E869CB9B4926D26435E6E7BB
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 RoyalBlue
#property indicator_color3 Red
#property indicator_color4 RoyalBlue

extern int MaMetod = 2;
extern int MaPeriod = 6;
extern int MaMetod2 = 3;
extern int MaPeriod2 = 2;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
int gi_124 = 0;

int init() {
   IndicatorBuffers(8);
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 1, Red);
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 1, RoyalBlue);
   SetIndexBuffer(1, g_ibuf_96);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red);
   SetIndexBuffer(2, g_ibuf_100);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, RoyalBlue);
   SetIndexBuffer(3, g_ibuf_104);
   SetIndexDrawBegin(0, 5);
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexBuffer(1, g_ibuf_96);
   SetIndexBuffer(2, g_ibuf_100);
   SetIndexBuffer(3, g_ibuf_104);
   SetIndexBuffer(4, g_ibuf_108);
   SetIndexBuffer(5, g_ibuf_112);
   SetIndexBuffer(6, g_ibuf_116);
   SetIndexBuffer(7, g_ibuf_120);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double l_ima_0;
   double l_ima_8;
   double l_ima_16;
   double l_ima_24;
   double ld_32;
   double ld_40;
   double ld_48;
   double ld_56;
   if (Bars <= 10) return (0);
   gi_124 = IndicatorCounted();
   if (gi_124 < 0) return (-1);
   if (gi_124 > 0) gi_124--;
   int li_64 = Bars - gi_124 - 1;
   int li_68 = li_64;
   while (li_64 >= 0) {
      l_ima_0 = iMA(NULL, 0, MaPeriod, 0, MaMetod, PRICE_CLOSE, li_64);
      l_ima_8 = iMA(NULL, 0, MaPeriod, 0, MaMetod, PRICE_LOW, li_64);
      l_ima_16 = iMA(NULL, 0, MaPeriod, 0, MaMetod, PRICE_OPEN, li_64);
      l_ima_24 = iMA(NULL, 0, MaPeriod, 0, MaMetod, PRICE_HIGH, li_64);
      ld_32 = (g_ibuf_108[li_64 + 1] + (g_ibuf_112[li_64 + 1])) / 2.0;
      ld_56 = (l_ima_0 + l_ima_24 + l_ima_16 + l_ima_8) / 4.0;
      ld_40 = MathMax(l_ima_24, MathMax(ld_32, ld_56));
      ld_48 = MathMin(l_ima_16, MathMin(ld_32, ld_56));
      if (ld_32 < ld_56) {
         g_ibuf_116[li_64] = ld_48;
         g_ibuf_120[li_64] = ld_40;
      } else {
         g_ibuf_116[li_64] = ld_40;
         g_ibuf_120[li_64] = ld_48;
      }
      g_ibuf_108[li_64] = ld_32;
      g_ibuf_112[li_64] = ld_56;
      li_64--;
   }
   for (int li_72 = 0; li_72 < li_68; li_72++) g_ibuf_92[li_72] = iMAOnArray(g_ibuf_116, Bars, MaPeriod2, 0, MaMetod2, li_72);
   for (li_72 = 0; li_72 < li_68; li_72++) g_ibuf_96[li_72] = iMAOnArray(g_ibuf_120, Bars, MaPeriod2, 0, MaMetod2, li_72);
   for (li_72 = 0; li_72 < li_68; li_72++) g_ibuf_100[li_72] = iMAOnArray(g_ibuf_108, Bars, MaPeriod2, 0, MaMetod2, li_72);
   for (li_72 = 0; li_72 < li_68; li_72++) g_ibuf_104[li_72] = iMAOnArray(g_ibuf_112, Bars, MaPeriod2, 0, MaMetod2, li_72);
   return (0);
}
