
#property copyright "Wiper Publishing"
#property link      "http://www.forexscanners.com"

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

string gs_unused_76 = "Last Modified: 2008.07.01 04:25";
double g_ibuf_84[];
double g_ibuf_88[];
extern bool AlertOn = TRUE;
int gi_unused_96 = 0;
extern int expiration_date = D'08.10.2010 06:00';
string gs_104 = "Your trail/subscription period is over! Please go to http://www.forexscanners.com to subscribe.";
int g_bars_112 = 0;
int g_bars_116 = 0;
int g_bars_120 = 0;
int g_bars_124 = 0;

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);
}

int deinit() {
   return (0);
}

int start() {
   int li_8;
   string ls_12;
   if (TimeCurrent() >= expiration_date) {
      Alert(gs_104);
      return (0);
   }
   int li_0 = 0;
   for (int li_4 = 5000; li_4 >= 1; li_4--) {
      li_8 = GetSignal(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 == 1) 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 = "ForexScannersTrend " + " " + Symbol() + " " + Period() + " Min -  All Indicators UP - BULLISH TREND";
         AlertOnce(ls_12, 1);
      }
      if (g_ibuf_84[1] == 1.0 && g_ibuf_84[2] == 0.0) {
         ls_12 = "ForexScannersTrend " + " " + Symbol() + " " + Period() + " Min -  All Indicators DOWN - BEARISH TREND";
         AlertOnce(ls_12, 2);
      }
   }
   return (0);
}

int GetSignal(int ai_0) {
   double l_ima_4 = 0;
   double l_ima_12 = 0;
   double l_ima_20 = 0;
   double l_ima_28 = 0;
   double l_ima_36 = 0;
   double l_ima_44 = 0;
   double ld_unused_52 = 0;
   double ld_unused_60 = 0;
   l_ima_4 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, ai_0);
   l_ima_12 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_HIGH, ai_0);
   l_ima_20 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_LOW, ai_0);
   l_ima_28 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, ai_0 + 1);
   l_ima_36 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_HIGH, ai_0 + 1);
   l_ima_44 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_LOW, ai_0 + 1);
   ld_unused_52 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_CLOSE, ai_0);
   ld_unused_60 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_CLOSE, ai_0 + 25);
   if (l_ima_4 > l_ima_12 && l_ima_28 < l_ima_36) return (1);
   if (l_ima_4 < l_ima_20 && l_ima_28 > l_ima_44) return (2);
   return (0);
}

int AlertOnce(string as_0, int ai_8) {
   switch (ai_8) {
   case 1:
      if (g_bars_112 == 0 || g_bars_112 < Bars) {
         Alert(as_0);
         g_bars_112 = Bars;
         return (1);
      }
   case 2:
      if (g_bars_116 == 0 || g_bars_116 < Bars) {
         Alert(as_0);
         g_bars_116 = Bars;
         return (1);
      }
   case 3:
      if (g_bars_120 == 0 || g_bars_120 < Bars) {
         Alert(as_0);
         g_bars_120 = Bars;
         return (1);
      }
   case 4:
      if (g_bars_124 == 0 || g_bars_124 < Bars) {
         Alert(as_0);
         g_bars_124 = Bars;
         return (1);
      }
   }
   return (0);
}