/*
   Generated by EX4-TO-MQ4 decompiler V4.0.451.2 [-]
   Website: https://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2013, Rita Lasker"
#property link      "http://www.ritalasker.com"

#property indicator_chart_window
#property indicator_buffers    4

#include <WinUser32.mqh>
#import "kernel32.dll"
   void GetSystemTime(int& a0[]);
#import

string gs_76 = "Your version has expired!";
string gs_unused_84 = "NO VALID KEY";
string gs_92 = "2118.03.27";
string gs_100 = "Forex InfoBot";
string gs_108 = "Forex InfoBot: ";
string gs_116 = " Sell. TP=";
string gs_124 = ". SL=";
string gs_132 = "Forex InfoBot:";
string gs_140 = " Buy. TP=";
string gs_148 = ". SL=";
extern int arrow_size = 4;
extern int font_size1 = 20;
extern int font_size2 = 12;

double buy_buff[];
double buy_sl[];
double buy_tp[];

double sell_buff[];
double sell_sl[];
double sell_tp[];


int g_x_168 = 55;
int g_y_172 = 10;
int g_x_176 = 8;
int g_y_180 = 40;
int g_x_184 = 10;
int g_y_188 = 60;
int g_x_192 = 70;
int g_y_196 = 10;
int g_x_200 = 10;
int g_y_204 = 40;
int g_x_208 = 10;
int g_y_212 = 60;
bool gi_216 = FALSE;
int GmtOffSet = 0;
int gi_224 = 1;
int gi_228 = 6;
int gi_232 = 21;
extern bool UseAlert = TRUE;
bool gi_240 = TRUE;
int gi_244 = 10;
bool gi_248 = TRUE;
int gi_252;
int gi_256;
bool gi_260 = TRUE;
bool gi_264 = TRUE;
bool gi_268 = TRUE;
bool gi_272 = TRUE;
double gd_276;
double gd_284;
double gd_292;
double gd_300;
double gd_308;
double gd_316;
int g_datetime_324;
int g_datetime_328;
int gi_332;
double gd_336;
int gi_344 = 1;
int gi_348;
int g_datetime_352 = 0;

int init() 
{
   IndicatorBuffers(4);
   SetIndexBuffer(0,buy_buff);
   SetIndexBuffer(1,buy_tp);
   SetIndexBuffer(2,sell_buff);
   SetIndexBuffer(3,sell_tp);

   if (arrow_size < 1) arrow_size = 1;
   if (arrow_size > 5) arrow_size = 5;
   gd_336 = Point;
   if (Digits == 5 || Digits == 3) gd_336 = 10.0 * gd_336;
   if (IsTesting()) {
      if (gi_216) {
         MessageBoxA(0, "AutoTimeSettings should be (false) at the test mode. Using ManualGMT_Offset", "Error", 0);
         gi_248 = FALSE;
         return (0);
      }
      gi_252 = GmtOffSet;
   }
   gi_252 = GmtOffSet;
   if (gi_216) gi_252 = f0_0();
   gi_256 = 3600 * gi_252;
   if (gi_256 >= 0) gi_332 = iTime(Symbol(), PERIOD_D1, 0) + gi_256;
   else gi_332 = iTime(Symbol(), PERIOD_D1, 1) + 86400 + gi_256;

/*
   if (gs_92 != "") 
   {
      if (TimeCurrent() > StrToTime(gs_92) + 86400 * gi_344) {
         MessageBoxA(0, gs_76, "expired", 0);
         Comment(gs_76);
         gi_248 = FALSE;
         return (0);
      }
   } */
   return (0);
}

int deinit() {
   string name_0;
   int objs_total_8 = ObjectsTotal();
   for (int li_12 = objs_total_8 - 1; li_12 >= 0; li_12--) {
      name_0 = ObjectName(li_12);
      if (StringFind(name_0, "[Calc]", 0) >= 0 || StringFind(name_0, "ARROW", 0) >= 0) ObjectDelete(name_0);
   }
   ObjectDelete("BuyS");
   ObjectDelete("TPBuy");
   ObjectDelete("SLBuy");
   ObjectDelete("SellS");
   ObjectDelete("TPSell");
   ObjectDelete("SLSell");
   Comment("");
   return (0);
}

int start() {
   string ls_unused_16;
   string name_24;
   string text_32;
   color color_40;
   string text_44;
   string text_52;
   string text_60;
   string text_68;
   string text_76;
   //if (!gi_248) return (0);
   
   if (gi_348 < 25) gi_348++;
   if (gi_348 == 25) {
   }
   if (f0_1()) 
   {
      if (Open[1] < gd_292 && Close[1] < gd_292 && Close[0] >= gd_292 && gi_260) {
         gi_260 = FALSE;
         g_datetime_324 = TimeCurrent();
         if (gi_268 && UseAlert) {
            Alert(gs_132 + Symbol() + gs_140 + DoubleToStr(gd_308, Digits) + gs_148 + DoubleToStr(gd_300, Digits) + ".");
            SendMail(gs_100, gs_132 + Symbol() + gs_140 + DoubleToStr(gd_308, Digits) + gs_148 + DoubleToStr(gd_300, Digits) + ".");
            gi_268 = FALSE;
         }
         name_24 = "BuyARROW" + Time[0];
         ObjectCreate(name_24, OBJ_ARROW, 0, 0, 0);
         ObjectSet(name_24, OBJPROP_ARROWCODE, 233);
         ObjectSet(name_24, OBJPROP_WIDTH, arrow_size);
         ObjectSet(name_24, OBJPROP_COLOR, Blue);
         ObjectSet(name_24, OBJPROP_PRICE1, Low[0] - 50.0 * gd_336);
         ObjectSet(name_24, OBJPROP_TIME1, Time[0]);
         if (ObjectFind("BuyS") == -1) {
            ObjectCreate("BuyS", OBJ_LABEL, 0, 0, 0);
            ObjectSet("BuyS", OBJPROP_CORNER, 1);
            ObjectSet("BuyS", OBJPROP_XDISTANCE, g_x_168);
            ObjectSet("BuyS", OBJPROP_YDISTANCE, g_y_172);
            text_32 = "BUY!";
            color_40 = Blue;
            ObjectSetText("BuyS", text_32, font_size1, "Arial Black", color_40);
         }
         if (ObjectFind("TPBuy") == -1) {
            ObjectCreate("TPBuy", OBJ_LABEL, 0, 0, 0);
            ObjectSet("TPBuy", OBJPROP_CORNER, 1);
            ObjectSet("TPBuy", OBJPROP_XDISTANCE, g_x_176);
            ObjectSet("TPBuy", OBJPROP_YDISTANCE, g_y_180);
            text_44 = "TP = " + DoubleToStr(gd_308, Digits);
            ObjectSetText("TPBuy", text_44, font_size2, "Arial Black", color_40);
         }
         if (ObjectFind("SLBuy") == -1) {
            ObjectCreate("SLBuy", OBJ_LABEL, 0, 0, 0);
            ObjectSet("SLBuy", OBJPROP_CORNER, 1);
            ObjectSet("SLBuy", OBJPROP_XDISTANCE, g_x_184);
            ObjectSet("SLBuy", OBJPROP_YDISTANCE, g_y_188);
            text_52 = "SL = " + DoubleToStr(gd_300, Digits);
            ObjectSetText("SLBuy", text_52, font_size2, "Arial Black", color_40);
         }
      }
      if (Open[1] > gd_300 && Close[1] > gd_300 && Close[0] <= gd_300 && gi_264) 
      {
         gi_264 = FALSE;
         g_datetime_328 = TimeCurrent();
         if (gi_272 && UseAlert) 
         {
            Alert(gs_108 + Symbol() + gs_116 + DoubleToStr(gd_316, Digits) + gs_124 + DoubleToStr(gd_292, Digits) + ".");
            SendMail(gs_100, gs_108 + Symbol() + gs_116 + DoubleToStr(gd_316, Digits) + gs_124 + DoubleToStr(gd_292, Digits) + ".");
            gi_272 = FALSE;
         }
         name_24 = "SellARROW" + Time[0];
         ObjectCreate(name_24, OBJ_ARROW, 0, 0, 0);
         ObjectSet(name_24, OBJPROP_ARROWCODE, 234);
         ObjectSet(name_24, OBJPROP_WIDTH, arrow_size);
         ObjectSet(name_24, OBJPROP_COLOR, Red);
         ObjectSet(name_24, OBJPROP_PRICE1, High[0] + 50.0 * gd_336);
         ObjectSet(name_24, OBJPROP_TIME1, Time[0]);
         if (ObjectFind("SellS") == -1) 
         {
            ObjectCreate("SellS", OBJ_LABEL, 0, 0, 0);
            ObjectSet("SellS", OBJPROP_CORNER, 1);
            ObjectSet("SellS", OBJPROP_XDISTANCE, g_x_192);
            ObjectSet("SellS", OBJPROP_YDISTANCE, g_y_196);
            text_60 = "Sell!";
            color_40 = Red;
            ObjectSetText("SellS", text_60, font_size1, "Arial Black", color_40);
         }
         if (ObjectFind("TPSell") == -1) {
            ObjectCreate("TPSell", OBJ_LABEL, 0, 0, 0);
            ObjectSet("TPSell", OBJPROP_CORNER, 1);
            ObjectSet("TPSell", OBJPROP_XDISTANCE, g_x_200);
            ObjectSet("TPSell", OBJPROP_YDISTANCE, g_y_204);
            text_68 = "TP = " + DoubleToStr(gd_316, Digits);
            ObjectSetText("TPSell", text_68, font_size2, "Arial Black", color_40);
         }
         if (ObjectFind("SLSell") == -1) {
            ObjectCreate("SLSell", OBJ_LABEL, 0, 0, 0);
            ObjectSet("SLSell", OBJPROP_CORNER, 1);
            ObjectSet("SLSell", OBJPROP_XDISTANCE, g_x_208);
            ObjectSet("SLSell", OBJPROP_YDISTANCE, g_y_212);
            text_76 = "SL = " + DoubleToStr(gd_292, Digits);
            ObjectSetText("SLSell", text_76, font_size2, "Arial Black", color_40);
         }
      }
   } else {
      ObjectDelete("BuyS");
      ObjectDelete("TPBuy");
      ObjectDelete("SLBuy");
      ObjectDelete("SellS");
      ObjectDelete("TPSell");
      ObjectDelete("SLSell");
   }
   if (Close[0] >= gd_308 || TimeCurrent() > g_datetime_324 + 600) {
      ObjectDelete("BuyS");
      ObjectDelete("TPBuy");
      ObjectDelete("SLBuy");
   }
   if (Close[0] <= gd_316 || TimeCurrent() > g_datetime_328 + 600) {
      ObjectDelete("SellS");
      ObjectDelete("TPSell");
      ObjectDelete("SLSell");
   }
   if (TimeCurrent() - g_datetime_352 < 600) return (0);
   g_datetime_352 = TimeCurrent();
   if (Period() > PERIOD_D1) {
      Print("Error - Chart period is greater than 1 day.");
      return (-1);
   }
   int li_84 = 0;
   double ld_unused_88 = 0;
   double ld_unused_96 = 0;
   double high_104 = 0;
   double ld_unused_112 = 0;
   double low_120 = 0;
   double close_128 = 0;
   double ld_unused_136 = 0;
   double ld_unused_144 = 0;
   double ld_unused_152 = 0;
   if (IsTesting()) {
      if (gi_216) {
         MessageBoxA(0, "AutoTimeSettings should be (false) at the test mode. Using ManualGMT_Offset", "Error", 0);
         gi_248 = FALSE;
         return (0);
      }
      gi_252 = GmtOffSet;
   }
   gi_252 = GmtOffSet;
   if (gi_216) gi_252 = f0_0();
   gi_256 = 3600 * gi_252;
   if (gi_256 >= 0) {
      if (gi_332 < iTime(Symbol(), PERIOD_D1, 0) + gi_256 && TimeCurrent() >= iTime(Symbol(), PERIOD_D1, 0) + gi_256) {
         gi_332 = iTime(Symbol(), PERIOD_D1, 0) + gi_256;
         gi_260 = TRUE;
         gi_264 = TRUE;
         gi_268 = TRUE;
         gi_272 = TRUE;
         ObjectDelete("BuyS");
         ObjectDelete("TPBuy");
         ObjectDelete("SLBuy");
         ObjectDelete("SellS");
         ObjectDelete("TPSell");
         ObjectDelete("SLSell");
      }
   } else {
      if (gi_332 < iTime(Symbol(), PERIOD_D1, 1) + 86400 + gi_256 && TimeCurrent() >= iTime(Symbol(), PERIOD_D1, 1) + 86400 + gi_256) {
         gi_332 = iTime(Symbol(), PERIOD_D1, 1) + 86400 + gi_256;
         gi_260 = TRUE;
         gi_264 = TRUE;
         gi_268 = TRUE;
         gi_272 = TRUE;
         ObjectDelete("BuyS");
         ObjectDelete("TPBuy");
         ObjectDelete("SLBuy");
         ObjectDelete("SellS");
         ObjectDelete("TPSell");
         ObjectDelete("SLSell");
      }
   }
   int ind_counted_160 = IndicatorCounted();
   double high_164 = 0;
   double low_172 = 0;
   int li_180 = Bars - ind_counted_160;
   int day_of_week_184 = TimeDayOfWeek(Time[li_180] - gi_256);
   if (li_84 < iTime(Symbol(), PERIOD_D1, 0) + gi_256) {
      if (TimeCurrent() >= iTime(Symbol(), PERIOD_D1, 0) + gi_256) li_84 = iTime(Symbol(), PERIOD_D1, 0) + gi_256;
      else li_84 = iTime(Symbol(), PERIOD_D1, 1) + gi_256;
   }
   int shift_188 = iBarShift(Symbol(), 0, li_84);
   high_164 = High[iHighest(Symbol(), 0, MODE_HIGH, 1440 / Period(), shift_188 + 1)];
   low_172 = Low[iLowest(Symbol(), 0, MODE_LOW, 1440 / Period(), shift_188 + 1)];
   double close_192 = Close[shift_188 + 1];
   close_128 = close_192;
   high_104 = high_164;
   low_120 = low_172;
   double ld_200 = (high_104 + low_120 + close_128) / 3.0;
   gd_276 = f0_4(2.0 * ld_200 - low_120);
   gd_292 = f0_4((ld_200 + gd_276) / 2.0);
   gd_308 = f0_4(ld_200 + (high_104 - low_120));
   gd_284 = f0_4(2.0 * ld_200 - high_104);
   gd_300 = f0_4((ld_200 + gd_284) / 2.0);
   gd_316 = f0_4(ld_200 - (high_104 - low_120));
   
   if (gi_240) 
   {
      f0_2("BuyLine",    gd_292, Blue, li_84);
      f0_2("BuyTPLine",  gd_308, Blue, li_84);
      f0_2("SellLine",   gd_300, Red, li_84);
      f0_2("SellTPLine", gd_316, Red, li_84);
      
   }

   buy_buff[0]  = gd_292;
   buy_tp[0]    = gd_308;
   sell_buff[0] = gd_300;
   sell_tp[0]   = gd_316;

 //  Comment("OFFSET = " + gi_252 + "  ");
   return (0);
}

void f0_2(string as_0, double a_price_8, color a_color_16, int ai_20) {
   string name_24 = "[Calc] " + as_0 + " Label";
   string name_32 = "[Calc] " + as_0;
   int li_unused_40 = MarketInfo(Symbol(), MODE_DIGITS);
   if (ObjectFind(name_24) != 0) ObjectCreate(name_24, OBJ_TEXT, 0, MathMin(Time[gi_244], ai_20), a_price_8);
   else ObjectMove(name_24, 0, MathMin(Time[gi_244], ai_20), a_price_8);
   ObjectSetText(name_24, " " + as_0 + ": " + DoubleToStr(a_price_8, Digits), 8, "Arial", White);
   if (ObjectFind(name_32) != 0) {
      ObjectCreate(name_32, OBJ_TREND, 0, ai_20, a_price_8, ai_20 + 86400, a_price_8);
      ObjectSet(name_32, OBJPROP_STYLE, STYLE_DASHDOTDOT);
      ObjectSet(name_32, OBJPROP_COLOR, a_color_16);
      return;
   }
   ObjectMove(name_32, 1, Time[0], a_price_8);
   ObjectMove(name_32, 0, ai_20, a_price_8);
}

double f0_4(double ad_0) {
   return (NormalizeDouble(ad_0, Digits));
}

int f0_3() {
   int lia_0[4];
   GetSystemTime(lia_0);
   string ls_4 = (lia_0[0] & 65535) + "." + (lia_0[0] >> 16) + "." + (lia_0[1] >> 16) + " " + (lia_0[2] & 65535) + ":" + (lia_0[2] >> 16) + ":" + (lia_0[3] & 65535);
   return (StrToTime(ls_4));
}

int f0_0() {
   int li_0 = f0_3();
   double ld_4 = TimeCurrent() - li_0;
   ld_4 /= 3600.0;
   ld_4 = MathRound(ld_4);
   int li_ret_12 = ld_4;
   return (li_ret_12);
}

int f0_1() 
{
   if (gi_224 == 0) return (1);
   if (gi_228 > 23) gi_228 -= 24;
   if (gi_232 > 23) gi_232 -= 24;
   bool li_ret_0 = FALSE;
   if (gi_228 < gi_232) {
      if (gi_228 + 1 <= Hour() && Hour() < gi_232) li_ret_0 = TRUE;
   } else
      if (gi_228 + 1 <= Hour() || Hour() < gi_232) li_ret_0 = TRUE;
   return (li_ret_0);
}

