#property copyright "Copyright © 2007, Dariuske"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 OrangeRed

extern double Angle = 0.2;
extern int CountBars = 500;
extern bool UseAlert = TRUE;
double gda_unused_92[];
double gda_unused_96[];
double g_ibuf_108[];
double g_ibuf_112[];
string gs_120 = "";
int g_time_128 = 0;

int init() {
   string ls_unused_0;
   IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 108);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 108);
   SetIndexBuffer(0, g_ibuf_108);
   SetIndexBuffer(1, g_ibuf_112);
   return (0);
}

int start() {
   double l_ima_24;
   double l_ima_32;
   double l_ima_40;
   double l_icustom_48;
   int li_8 = IndicatorCounted();
   if (li_8 < 0) return (-1);
   if (li_8 > 0) li_8--;
   int li_12 = Bars - li_8;
   /*if (Time[0] >= StrToTime("2007.02.01")) {
      Comment("This Indicator Expired");
      return;
   }*/
   for (int li_4 = CountBars; li_4 >= 0; li_4--) {
      l_ima_24 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_4);
      l_ima_32 = iMA(NULL, 0, 21, 0, MODE_EMA, PRICE_CLOSE, li_4);
      l_ima_40 = iMA(NULL, 0, 50, 0, MODE_SMA, PRICE_CLOSE, li_4);
      l_icustom_48 = iCustom(NULL, 0, "SMAAngle", 50, 0.15, 2, 0, 0, li_4);
      g_ibuf_108[li_4] = 0;
      g_ibuf_112[li_4] = 0;
      if (l_icustom_48 <= (-Angle) && l_ima_24 < l_ima_32 && l_ima_32 < l_ima_40 && (Close[li_4] > l_ima_24 && Close[li_4] < l_ima_32) || (Open[li_4] > l_ima_24 && Open[li_4] < l_ima_32)) {
         g_ibuf_112[li_4] = High[li_4] + 6.0 * Point;
         if (li_4 < 2) {
            gs_120 = "DOWN.";
            DoAlert(gs_120);
         }
      }
      if (l_icustom_48 >= Angle && l_ima_24 > l_ima_32 && l_ima_32 > l_ima_40 && (Close[li_4] < l_ima_24 && Close[li_4] > l_ima_32) || (Open[li_4] < l_ima_24 && Open[li_4] > l_ima_32)) {
         g_ibuf_108[li_4] = Low[li_4] - 6.0 * Point;
         if (li_4 < 2) {
            gs_120 = " UP.";
            DoAlert(gs_120);
         }
      }
   }
   return (0);
}

void DoAlert(string as_0) {
   if (!NewBar() || !UseAlert) return;
   Alert(Symbol(), " ", Period(), " Phil Nel Signals", as_0);
}

int NewBar() {
   if (g_time_128 != Time[0]) {
      g_time_128 = Time[0];
      return (1);
   }
   return (0);
}
