
#property copyright "Copyright © 2009, Anne"
#property link      "http://xxx"

#property indicator_separate_window
#property indicator_minimum -0.5
#property indicator_maximum 5.0
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
#property indicator_color5 Red
#property indicator_color6 Blue
#property indicator_color7 Red
#property indicator_color8 Blue

double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
extern double Space = 1.0;
extern int Period_1 = 5;
extern int Period_2 = 15;
extern int Period_3 = 30;
extern int Period_4 = 60;
int g_period_132 = 50;
string gs_136 = "";
bool gi_144 = TRUE;
int gi_148 = 229;
int g_time_152 = 0;

int init() {
   gs_136 = "TudorGirl HG_0001a_MTF (" + Period_1 + "," + Period_2 + "," + Period_3 + "," + Period_4 + ")";
   gi_144 = TRUE;
   IndicatorShortName(gs_136);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 110);
   SetIndexEmptyValue(0, 0.0);
   SetIndexBuffer(1, g_ibuf_80);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 110);
   SetIndexEmptyValue(1, 0.0);
   SetIndexBuffer(2, g_ibuf_84);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 110);
   SetIndexEmptyValue(2, 0.0);
   SetIndexBuffer(3, g_ibuf_88);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 110);
   SetIndexEmptyValue(3, 0.0);
   SetIndexBuffer(4, g_ibuf_92);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 110);
   SetIndexEmptyValue(4, 0.0);
   SetIndexBuffer(5, g_ibuf_96);
   SetIndexStyle(5, DRAW_ARROW);
   SetIndexArrow(5, 110);
   SetIndexEmptyValue(5, 0.0);
   SetIndexBuffer(6, g_ibuf_100);
   SetIndexStyle(6, DRAW_ARROW);
   SetIndexArrow(6, 110);
   SetIndexEmptyValue(6, 0.0);
   SetIndexBuffer(7, g_ibuf_104);
   SetIndexStyle(7, DRAW_ARROW);
   SetIndexArrow(7, 110);
   SetIndexEmptyValue(7, 0.0);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_24;
   int lia_32[];
   int lia_36[];
   int lia_40[];
   int lia_44[];
   int li_48;
   double ld_52;
   double ld_64;
   string l_text_72;
   double l_price_80;
   string l_name_92;
   int l_timeframe_104;
   double l_icci_112;
   double ld_120;
   double ld_unused_128;
   int l_ind_counted_0 = IndicatorCounted();
   int l_index_4 = 0;
   int l_index_8 = 0;
   int l_index_12 = 0;
   int l_index_16 = 0;
   int l_index_20 = 0;
   int li_28 = Bars - l_ind_counted_0;
   if (gi_144 || NewBar()) {
      gi_144 = FALSE;
      li_48 = gi_148;
      ld_52 = Time[0] - Time[1];
      for (int li_60 = ObjectsTotal() - 1; li_60 > -1; li_60--) {
         if (StringFind(ObjectName(li_60), "HG_" + li_48 + "_") >= 0) ObjectDelete(ObjectName(li_60));
         else li_60 = -1;
      }
      ld_64 = 0.2;
      for (li_60 = 0; li_60 < 4; li_60++) {
         l_text_72 = "??";
         switch (li_60) {
         case 0:
            l_text_72 = tf2txt(Period_1);
            l_price_80 = 0.0 * Space + 1.0 + ld_64;
            break;
         case 1:
            l_text_72 = tf2txt(Period_2);
            l_price_80 = 1.0 * Space + 1.0 + ld_64;
            break;
         case 2:
            l_text_72 = tf2txt(Period_3);
            l_price_80 = 2.0 * Space + 1.0 + ld_64;
            break;
         case 3:
            l_text_72 = tf2txt(Period_4);
            l_price_80 = 3.0 * Space + 1.0 + ld_64;
         }
         l_name_92 = "HG_" + li_48 + "_" + li_60 + "_" + l_text_72;
         ObjectCreate(l_name_92, OBJ_TEXT, WindowFind(gs_136), iTime(NULL, 0, 0) + 3.0 * ld_52, l_price_80);
         ObjectSetText(l_name_92, l_text_72, 8, "Arial", Silver);
      }
   }
   ArrayCopySeries(lia_32, 5, Symbol(), Period_1);
   ArrayCopySeries(lia_36, 5, Symbol(), Period_2);
   ArrayCopySeries(lia_40, 5, Symbol(), Period_3);
   ArrayCopySeries(lia_44, 5, Symbol(), Period_4);
   l_index_4 = 0;
   l_index_8 = 0;
   l_index_12 = 0;
   l_index_16 = 0;
   l_index_20 = 0;
   while (l_index_4 < li_28) {
      if (Time[l_index_4] < lia_32[l_index_8]) l_index_8++;
      if (Time[l_index_4] < lia_36[l_index_12]) l_index_12++;
      if (Time[l_index_4] < lia_40[l_index_16]) l_index_16++;
      if (Time[l_index_4] < lia_44[l_index_20]) l_index_20++;
      for (int l_count_100 = 0; l_count_100 < 4; l_count_100++) {
         switch (l_count_100) {
         case 0:
            l_timeframe_104 = Period_1;
            li_24 = l_index_8;
            break;
         case 1:
            l_timeframe_104 = Period_2;
            li_24 = l_index_12;
            break;
         case 2:
            l_timeframe_104 = Period_3;
            li_24 = l_index_16;
            break;
         case 3:
            l_timeframe_104 = Period_4;
            li_24 = l_index_20;
         }
         l_icci_112 = iCCI(NULL, l_timeframe_104, g_period_132, PRICE_TYPICAL, li_24);
         ld_120 = EMPTY_VALUE;
         ld_unused_128 = EMPTY_VALUE;
         if (l_icci_112 < 0.0) ld_120 = 1;
         else ld_unused_128 = 1;
         switch (l_count_100) {
         case 0:
            if (ld_120 == EMPTY_VALUE) g_ibuf_80[l_index_4] = 0.0 * Space + 1.0;
            else g_ibuf_76[l_index_4] = 0.0 * Space + 1.0;
            break;
         case 1:
            if (ld_120 == EMPTY_VALUE) g_ibuf_88[l_index_4] = 1.0 * Space + 1.0;
            else g_ibuf_84[l_index_4] = 1.0 * Space + 1.0;
            break;
         case 2:
            if (ld_120 == EMPTY_VALUE) g_ibuf_96[l_index_4] = 2.0 * Space + 1.0;
            else g_ibuf_92[l_index_4] = 2.0 * Space + 1.0;
            break;
         case 3:
            if (ld_120 == EMPTY_VALUE) g_ibuf_104[l_index_4] = 3.0 * Space + 1.0;
            else g_ibuf_100[l_index_4] = 3.0 * Space + 1.0;
         }
      }
      l_index_4++;
   }
   return (0);
}

string tf2txt(int ai_0) {
   if (ai_0 == 1) return ("M1");
   if (ai_0 == 5) return ("M5");
   if (ai_0 == 15) return ("M15");
   if (ai_0 == 30) return ("M30");
   if (ai_0 == 60) return ("H1");
   if (ai_0 == 240) return ("H4");
   if (ai_0 == 1440) return ("D1");
   if (ai_0 == 10080) return ("W1");
   if (ai_0 == 43200) return ("MN1");
   return ("??");
}

int NewBar() {
   if (Time[0] != g_time_152) {
      g_time_152 = Time[0];
      return (1);
   }
   return (0);
}