/*
  
*/
#property copyright "Copyright © 2008, Forex Day Monster"
#property link      "http://www.forexprofitmonster.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

double g_ibuf_76[];
double g_ibuf_80[];
int g_period_84 = 3;
int g_period_88 = 21;
extern bool Alerts = TRUE;
int gi_96 = 0;
int gi_100 = 0;

int init() {
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, g_ibuf_80);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_20;
   double l_ima_24;
   double l_ima_32;
   double l_ima_40;
   double l_ima_48;
   double l_ima_56;
   double l_ima_64;
   double ld_72;
   double ld_80;
   string ls_0 = "2015.11.01";
   int l_str2time_8 = StrToTime(ls_0);
   if (TimeCurrent() >= l_str2time_8) {
      Alert(" Trial version has expired! Email support@forexprofitmonster.com with broker account number for rights to full version!");
      return (0);
   }
   int li_88 = IndicatorCounted();
   if (li_88 < 0) return (-1);
   if (li_88 > 0) li_88--;
   int li_12 = Bars - li_88;
   for (int li_16 = 0; li_16 <= li_12; li_16++) {
      li_20 = li_16;
      ld_72 = 0;
      ld_80 = 0;
      for (li_20 = li_16; li_20 <= li_16 + 9; li_20++) ld_80 += MathAbs(High[li_20] - Low[li_20]);
      ld_72 = ld_80 / 10.0;
      l_ima_24 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_16);
      l_ima_40 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_16 + 1);
      l_ima_56 = iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_16 - 1);
      l_ima_32 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_16);
      l_ima_48 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_16 + 1);
      l_ima_64 = iMA(NULL, 0, g_period_88, 0, MODE_EMA, PRICE_CLOSE, li_16 - 1);
      if (l_ima_24 > l_ima_32 && l_ima_40 < l_ima_48 && l_ima_56 > l_ima_64) {
         g_ibuf_76[li_16] = Low[li_16] - ld_72 / 2.0;
         if (li_16 <= 2 && Alerts && !gi_96) {
            Alert(Symbol(), " ", Period(), " Day Monster BUY Alert ");
            gi_96 = TRUE;
            gi_100 = FALSE;
         }
      } else {
         if (l_ima_24 < l_ima_32 && l_ima_40 > l_ima_48 && l_ima_56 < l_ima_64) {
            g_ibuf_80[li_16] = High[li_16] + ld_72 / 2.0;
            if (li_16 <= 2 && Alerts && !gi_100) {
               Alert(Symbol(), " ", Period(), " Day Monster SELL Alert ");
               gi_100 = TRUE;
               gi_96 = FALSE;
            }
         }
      }
   }
   return (0);
}