#property copyright "Expert Advisor Builder"
#property link      "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern bool EachTickMode = TRUE;
extern int Slippage = 3;
string gs_dummy_88;
string gs_dummy_96;
bool gi_unused_104 = FALSE;
int g_bars_108;
int gi_112;
bool gi_116 = FALSE;
int g_time_120 = 0;
int g_time_124 = 0;
int g_time_128 = 0;
int g_time_132 = 0;

int init() {
   g_bars_108 = Bars;
   if (EachTickMode) gi_112 = 0;
   else gi_112 = 1;
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_0 = 0;
   int li_4 = 5;
   if (EachTickMode && Bars != g_bars_108) gi_116 = FALSE;
   int order_total_8 = OrdersTotal();
   li_0 = 0;
   li_4 = 5;
   gi_unused_104 = FALSE;
   double icustom_32 = iCustom(NULL, 0, "Chin-C", 0, gi_112 + 0);
   double ld_40 = 1500;
   double icustom_48 = iCustom(NULL, 0, "Chin-C", 0, gi_112 + 1);
   double ld_56 = 1500;
   double icustom_64 = iCustom(NULL, 0, "Chin-D", 0, gi_112 + 0);
   double ld_72 = 1500;
   double icustom_80 = iCustom(NULL, 0, "Chin-D", 0, gi_112 + 1);
   double ld_88 = 1500;
   double icustom_96 = iCustom(NULL, 0, "Chin-C", 0, gi_112 + 0);
   double ld_104 = -1500;
   double icustom_112 = iCustom(NULL, 0, "Chin-C", 0, gi_112 + 1);
   double ld_120 = -1500;
   double icustom_128 = iCustom(NULL, 0, "Chin-D", 0, gi_112 + 0);
   double ld_136 = -1500;
   double icustom_144 = iCustom(NULL, 0, "Chin-D", 0, gi_112 + 1);
   double ld_unused_152 = -1500;
   datetime lt_160 = D'31.08.2019 02:00';
   if (TimeCurrent() >= lt_160) {
      Alert("The trial version has been expired! Please contact chinstar16@gmail.com");
      return (0);
   }
   int bars_164 = Bars;
   if (bars_164 > 0) {
      if ((icustom_32 >= ld_40 && icustom_48 < ld_56) || (icustom_64 >= ld_72 && icustom_80 < ld_88)) li_4 = 6;
      if (icustom_32 >= ld_40 && icustom_64 >= ld_72 && icustom_48 <= ld_56 || icustom_80 <= ld_88) li_0 = 1;
      if ((icustom_96 <= ld_104 && icustom_112 > ld_120) || (icustom_128 <= ld_136 && icustom_144 >= ld_120)) li_4 = 7;
      if (icustom_96 <= ld_104 && icustom_128 <= ld_136 && icustom_112 >= ld_120 || icustom_144 >= ld_120) li_0 = 2;
      if (li_4 == 6 && f0_0()) {
         SendMail(" Possible BUY comingup on " + Symbol(), "");
         Alert("Possible BUY comingup on " + Symbol(), "");
      }
      if (li_0 == 1 && f0_3() && (EachTickMode && (!gi_116)) || (!EachTickMode && Bars != g_bars_108)) {
         Alert("BUY on " + Symbol(), "");
         SendMail("BUY on " + Symbol(), "");
         ObjectCreate("Up" + Bars, OBJ_ARROW, 0, Time[1], High[1] + 20.0 * Point);
         ObjectSet("Up" + Bars, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("Up" + Bars, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
         ObjectSet("Up" + Bars, OBJPROP_COLOR, Blue);
      }
      if (li_4 == 7 && f0_1()) {
         SendMail(" Possible SELL comingup on " + Symbol(), "");
         Alert("Possible SELL comingup on " + Symbol(), "");
      }
      if (li_0 == 2 && f0_2() && (EachTickMode && (!gi_116)) || (!EachTickMode && Bars != g_bars_108)) {
         Alert("SELL on " + Symbol(), "");
         SendMail("SELL on " + Symbol(), "");
         ObjectCreate("Down " + Bars, OBJ_ARROW, 0, Time[1], Low[1] - 20.0 * Point);
         ObjectSet("Down " + Bars, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("Down " + Bars, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
         ObjectSet("Down " + Bars, OBJPROP_COLOR, Red);
      }
      if (!(!EachTickMode)) return (0);
      g_bars_108 = Bars;
      return (0);
   }
   return (0);
}

// 09470FB701C11F8B07320EA009403A60
int f0_0() {
   if (g_time_120 != Time[0]) {
      g_time_120 = Time[0];
      Sleep(100);
      return (1);
   }
   return (0);
}

// 152453C06E8AE364025ECBA96CB08E86
int f0_1() {
   if (g_time_124 != Time[0]) {
      g_time_124 = Time[0];
      Sleep(100);
      return (1);
   }
   return (0);
}

// BFDDB27080F1D480E2E9C24F7D1C5C69
int f0_3() {
   if (g_time_128 != Time[0]) {
      g_time_128 = Time[0];
      Sleep(100);
      return (1);
   }
   return (0);
}

// 49E01670781AF7B3288C9970DE90CE30
int f0_2() {
   if (g_time_132 != Time[0]) {
      g_time_132 = Time[0];
      Sleep(100);
      return (1);
   }
   return (0);
}
