/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/

#property indicator_separate_window
#property indicator_minimum 2.0
#property indicator_maximum 4.0
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Black
#property indicator_color4 Black

extern bool BE.Sound.Alert = FALSE;
extern bool BE.Mail.Alert = FALSE;
extern int BE.BarWidth = 5;
extern color BE.BarColorUp = Green;
extern color BE.BarColorDown = Red;
int gi_96 = 110;
double g_ibuf_100[];
double g_ibuf_104[];
int g_period_108 = 48;
int g_period_112 = 104;
int g_period_116 = 9;
double g_ibuf_120[];
double g_ibuf_124[];
string g_symbol_128;
string gs_136;
string gs_dummy_144;
int g_digits_152;
int g_timeframe_156;
datetime g_time_160;
string gs_unused_164 = "";
int gi_unused_172 = 16777215;
string gs_176;
string gs_192;
int gi_unused_204;
int g_acc_number_208;
double gd_216 = 3.0;
int g_color_224 = Red;
string gs_unused_228 = "Font Size";
int g_fontsize_236 = 20;
string gs_unused_240 = "Font Type";
string gs_verdana_248 = "Verdana";
string g_text_256 = ">>> Verifying Account <<<";
string g_text_264 = "";
string g_name_272 = "cmtagtpbi01";
string g_name_280 = "cmtagtpbi02";
bool gi_288 = FALSE;
int g_bool_292;

int init() {
   gi_unused_204 = 1;
   g_timeframe_156 = Period();
   gs_136 = TimeFrameToString(g_timeframe_156);
   g_symbol_128 = Symbol();
   g_digits_152 = Digits;
   gs_192 = "Power Trend " + Symbol() + " " + gs_136;
   gs_176 = gs_192 + "0";
   IndicatorShortName(gs_192);
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, BE.BarWidth, BE.BarColorUp);
   SetIndexArrow(0, gi_96);
   SetIndexBuffer(0, g_ibuf_100);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, BE.BarWidth, BE.BarColorDown);
   SetIndexArrow(1, gi_96);
   SetIndexBuffer(1, g_ibuf_104);
   SetIndexBuffer(2, g_ibuf_120);
   SetIndexBuffer(3, g_ibuf_124);
   IndicatorDigits(0);
   g_bool_292 = BE.Sound.Alert || BE.Mail.Alert;
   return (0);
}

int deinit() {
   ObjectDelete(g_name_272);
   ObjectDelete(g_name_280);
   Comment("");
   return (0);
}

int start() {
   int li_4;
   //int li_0 = 1181406;
   
   ObjectDelete(g_name_272);
   ObjectDelete(g_name_280);
   int li_8 = IndicatorCounted();
   if (li_8 > 0) li_8--;
   if (gi_288) li_4 = Bars - li_8;
   else li_4 = Bars;
   for (int li_12 = 0; li_12 < li_4; li_12++) {
      g_ibuf_104[li_12] = EMPTY_VALUE;
      g_ibuf_100[li_12] = EMPTY_VALUE;
      g_ibuf_120[li_12] = iMA(g_symbol_128, 0, g_period_108, 0, MODE_EMA, PRICE_CLOSE, li_12) - iMA(g_symbol_128, 0, g_period_112, 0, MODE_EMA, PRICE_CLOSE, li_12);
   }
   for (li_12 = 0; li_12 < li_4; li_12++) g_ibuf_124[li_12] = iMAOnArray(g_ibuf_120, Bars, g_period_116, 0, MODE_SMA, li_12);
   for (li_12 = 0; li_12 < li_4; li_12++) {
      if (g_ibuf_120[li_12] < g_ibuf_124[li_12]) g_ibuf_104[li_12] = gd_216;
      else g_ibuf_100[li_12] = gd_216;
   }
   if (li_12 > 100) gi_288 = TRUE;
   if (g_time_160 != Time[0] && g_bool_292) {
      if (g_ibuf_100[1] == gd_216 && g_ibuf_100[2] != gd_216) DoAlert(g_symbol_128 + "  " + gs_136 + " EZTrender-swing BUY!  " + DoubleToStr(Close[0], g_digits_152));
      if (g_ibuf_104[1] == gd_216 && g_ibuf_104[2] != gd_216) DoAlert(g_symbol_128 + "  " + gs_136 + " EZTrender-swing SELL SHORT! " + DoubleToStr(Close[0], g_digits_152));
   }
   return (0);
}

void DoAlert(string as_0) {
   if (g_time_160 != Time[0]) {
      if (BE.Sound.Alert) {
         g_time_160 = Time[0];
         Alert(as_0);
      }
      if (BE.Mail.Alert) {
         g_time_160 = Time[0];
         SendMail("WT", as_0);
      }
   }
}


string TimeFrameToString(int ai_0) {
   string ls_ret_4;
   switch (ai_0) {
   case 1:
      ls_ret_4 = "M1";
      break;
   case 5:
      ls_ret_4 = "M5";
      break;
   case 15:
      ls_ret_4 = "M15";
      break;
   case 30:
      ls_ret_4 = "M30";
      break;
   case 60:
      ls_ret_4 = "H1";
      break;
   case 240:
      ls_ret_4 = "H4";
      break;
   case 1440:
      ls_ret_4 = "D1";
      break;
   case 10080:
      ls_ret_4 = "W1";
      break;
   case 43200:
      ls_ret_4 = "MN";
   }
   return (ls_ret_4);
}