/*
   Generated by EX4-TO-MQ4 decompiler V4.0.223.1b []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2008, Eng. ForexSmartPips.com"
#property link      "www.forexsmartpips.com"

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Sienna
#property indicator_color4 Blue

extern int Sensetive = 200;
extern int DeadZonePip = 20;
extern int ExplosionPower = 15;
extern int TrendPower = 5;
extern bool AlertWindow = TRUE;
extern int AlertCount = 500;
extern bool AlertLong = TRUE;
extern bool AlertShort = TRUE;
extern bool AlertExitLong = TRUE;
extern bool AlertExitShort = TRUE;
double g_ibuf_116[];
double g_ibuf_120[];
double g_ibuf_124[];
double g_ibuf_128[];
int gi_132 = 1;
int gi_136 = 1;
int gi_140 = 1;
int gi_144 = 1;
int gi_148 = 0;
int gi_152 = -1;
double g_ask_156;
double g_bid_164;

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(3, DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(0, g_ibuf_116);
   SetIndexBuffer(1, g_ibuf_120);
   SetIndexBuffer(2, g_ibuf_124);
   SetIndexBuffer(3, g_ibuf_128);
   IndicatorShortName("Forex_Smart_Pips: [S(" + Sensetive + ") - DZ(" + DeadZonePip + ") - EP(" + ExplosionPower + ") - TP(" + TrendPower + ")]");
   return (0);
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_48;
   int li_64 = IndicatorCounted();
   string ls_68 = "2019.05.27";
   int l_str2time_76 = StrToTime(ls_68);
   if (TimeCurrent() >= l_str2time_76) {
      Alert(" Trial Version Has Expired! Please Visit www.ForexSmartPips.com to Get Rights A New Versions!");
      return (0);
   }
   if (li_64 < 0) return (-1);
   if (li_64 > 0) li_64--;
   int li_56 = Bars - li_64;
   for (int l_shift_60 = li_56 - 1; l_shift_60 >= 0; l_shift_60--) {
      ld_0 = (iMACD(NULL, 0, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, l_shift_60) - iMACD(NULL, 0, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, l_shift_60 + 1)) * Sensetive;
      ld_8 = (iMACD(NULL, 0, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, l_shift_60 + 2) - iMACD(NULL, 0, 20, 40, 9, PRICE_CLOSE, MODE_MAIN, l_shift_60 + 3)) * Sensetive;
      ld_16 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, l_shift_60) - iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, l_shift_60);
      ld_24 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, l_shift_60 + 1) - iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, l_shift_60 + 1);
      ld_32 = Point * DeadZonePip;
      g_ibuf_116[l_shift_60] = 0;
      g_ibuf_120[l_shift_60] = 0;
      g_ibuf_124[l_shift_60] = 0;
      g_ibuf_128[l_shift_60] = 0;
      if (ld_0 >= 0.0) g_ibuf_116[l_shift_60] = ld_0;
      if (ld_0 < 0.0) g_ibuf_120[l_shift_60] = -1.0 * ld_0;
      g_ibuf_124[l_shift_60] = ld_16;
      g_ibuf_128[l_shift_60] = ld_32;
      if (l_shift_60 == 0) {
         if (ld_0 > 0.0 && ld_0 > ld_16 && ld_0 > ld_32 && ld_16 > ld_32 && ld_16 > ld_24 && ld_0 > ld_8 && gi_132 < AlertCount && AlertLong == TRUE && Ask != g_ask_156) {
            ld_40 = 100.0 * (ld_0 - ld_8) / ld_0;
            ld_48 = 100.0 * (ld_16 - ld_24) / ld_16;
            g_ask_156 = Ask;
            if (ld_48 >= ExplosionPower && ld_40 >= TrendPower) {
               if (AlertWindow == TRUE) Alert(gi_132, "- ", Symbol(), " - ForexSmartPips BUY ", " (", DoubleToStr(g_ask_156, Digits), ") Trend PWR ", DoubleToStr(ld_40, 0), " - Exp PWR ", DoubleToStr(ld_48, 0));
               else Print(gi_132, "- ", Symbol(), " - ForexSmartPips BUY ", " (", DoubleToStr(g_ask_156, Digits), ") Trend PWR ", DoubleToStr(ld_40, 0), " - Exp PWR ", DoubleToStr(ld_48, 0));
               gi_132++;
            }
            gi_148 = 1;
         }
         if (ld_0 < 0.0 && MathAbs(ld_0) > ld_16 && MathAbs(ld_0) > ld_32 && ld_16 > ld_32 && ld_16 > ld_24 && MathAbs(ld_0) > MathAbs(ld_8) && gi_136 < AlertCount && AlertShort == TRUE &&
            Bid != g_bid_164) {
            ld_40 = 100.0 * (MathAbs(ld_0) - MathAbs(ld_8)) / MathAbs(ld_0);
            ld_48 = 100.0 * (ld_16 - ld_24) / ld_16;
            g_bid_164 = Bid;
            if (ld_48 >= ExplosionPower && ld_40 >= TrendPower) {
               if (AlertWindow == TRUE) Alert(gi_136, "- ", Symbol(), " - ForexSmartPips SELL ", " (", DoubleToStr(g_bid_164, Digits), ") Trend PWR ", DoubleToStr(ld_40, 0), " - Exp PWR ", DoubleToStr(ld_48, 0));
               else Print(gi_136, "- ", Symbol(), " - ForexSmartPips SELL ", " (", DoubleToStr(g_bid_164, Digits), ") Trend PWR ", DoubleToStr(ld_40, 0), " - Exp PWR ", DoubleToStr(ld_48, 0));
               gi_136++;
            }
            gi_148 = 2;
         }
         if (ld_0 > 0.0 && ld_0 < ld_16 && ld_0 < ld_8 && ld_8 > ld_24 && ld_0 > ld_32 && ld_16 > ld_32 && gi_140 <= AlertCount && AlertExitLong == TRUE && Bid != g_bid_164) {
            g_bid_164 = Bid;
            if (AlertWindow == TRUE) Alert(gi_140, "- ", Symbol(), " - Exit BUY or Do Not Take Any Positions", " ", DoubleToStr(g_bid_164, Digits));
            else Print(gi_140, "- ", Symbol(), " - Exit BUY or Do Not Take Any Positions", " ", DoubleToStr(g_bid_164, Digits));
            gi_148 = 3;
            gi_140++;
         }
         if (ld_0 < 0.0 && MathAbs(ld_0) < ld_16 && MathAbs(ld_0) < MathAbs(ld_8) && MathAbs(ld_8) > ld_24 && ld_0 > ld_32 && ld_16 > ld_32 && gi_144 <= AlertCount && AlertExitShort == TRUE &&
            Ask != g_ask_156) {
            g_ask_156 = Ask;
            if (AlertWindow == TRUE) Alert(gi_144, "- ", Symbol(), " - Exit SELL or Do Not Take Any Positions", " ", DoubleToStr(g_ask_156, Digits));
            else Print(gi_144, "- ", Symbol(), " - Exit SELL or Do Not Take Any Positions", " ", DoubleToStr(g_ask_156, Digits));
            gi_148 = 4;
            gi_144++;
         }
         gi_152 = gi_148;
      }
      if (gi_148 != gi_152) {
         gi_132 = 1;
         gi_136 = 1;
         gi_140 = 1;
         gi_144 = 1;
      }
   }
   return (0);
}