#property copyright "TLP"
#property link      "http://www.google.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Maroon

double G_ibuf_84[];
double G_ibuf_88[];
extern bool AlertOn = FALSE;
int G_bars_100 = 0;
int G_bars_104 = 0;
int G_bars_108 = 0;
int G_bars_112 = 0;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexLabel(0, "BUY");
   SetIndexLabel(1, "SELL");
   SetIndexBuffer(0, G_ibuf_88);
   SetIndexBuffer(1, G_ibuf_84);
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_8;
   string Ls_12;
   bool Li_0 = FALSE;
   for (int Li_4 = 5000; Li_4 >= 1; Li_4--) {
      Li_8 = f0_0(Li_4);
      G_ibuf_88[Li_4] = 0;
      G_ibuf_84[Li_4] = 0;
      if (Li_8 > 0) Li_0 = Li_8;
      if (Li_0 == TRUE) G_ibuf_88[Li_4] = 1;
      if (Li_0 == 2) G_ibuf_84[Li_4] = 1;
   }
   if (AlertOn) {
      Ls_12 = "";
      if (G_ibuf_88[1] == 1.0 && G_ibuf_88[2] == 0.0) {
         Ls_12 = "Trend" + " " + Symbol() + " " + Period() + " Min -  All Indicators UP - BULLISH TREND";
         f0_1(Ls_12, 1);
      }
      if (G_ibuf_84[1] == 1.0 && G_ibuf_84[2] == 0.0) {
         Ls_12 = "Trend" + " " + Symbol() + " " + Period() + " Min -  All Indicators DOWN - BEARISH TREND";
         f0_1(Ls_12, 2);
      }
   }
   return (0);
}

// 58DC7095ADFBAFD87BA304A65054E5B4
int f0_0(int Ai_0) {
   double ima_4 = 0;
   double ima_12 = 0;
   double ima_20 = 0;
   double ima_28 = 0;
   double ima_36 = 0;
   double ima_44 = 0;
   double ima_52 = 0;
   double ima_60 = 0;
   ima_4 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, Ai_0);
   ima_12 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_HIGH, Ai_0);
   ima_20 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_LOW, Ai_0);
   ima_28 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, Ai_0 + 1);
   ima_36 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_HIGH, Ai_0 + 1);
   ima_44 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_LOW, Ai_0 + 1);
   ima_52 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_CLOSE, Ai_0);
   ima_60 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_CLOSE, Ai_0 + 25);
   if (ima_4 > ima_12 && ima_28 < ima_36) return (1);
   if (ima_4 < ima_20 && ima_28 > ima_44) return (2);
   return (0);
}

// B6536DD2CF347501CA28FF28C27ACC31
int f0_1(string As_0, int Ai_8) {
   switch (Ai_8) {
   case 1:
      if (!(G_bars_100 == 0 || G_bars_100 < Bars)) break;
      Alert(As_0);
      G_bars_100 = Bars;
      return (1);
      break;
   case 2:
      if (!(G_bars_104 == 0 || G_bars_104 < Bars)) break;
      Alert(As_0);
      G_bars_104 = Bars;
      return (1);
      break;
   case 3:
      if (!(G_bars_108 == 0 || G_bars_108 < Bars)) break;
      Alert(As_0);
      G_bars_108 = Bars;
      return (1);
      break;
   case 4:
      if (!(G_bars_112 == 0 || G_bars_112 < Bars)) break;
      Alert(As_0);
      G_bars_112 = Bars;
      return (1);
      break;
   }
   return (0);
}