/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright (C) FXProIndicator.com"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_level1 -50.0
#property indicator_width2 2
#property indicator_level2 50.0

int gi_76 = 25;
int gi_80 = 3000;
extern bool soundAlerts = TRUE;
extern bool emailAlerts = FALSE;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
int gi_104;
int g_count_108;
int gi_112;
bool gi_116;
int g_ind_counted_120;
datetime g_time_124;
datetime g_time_128;
datetime g_time_132;
double gd_136;
double gd_144;
double gd_152;
double gd_160;
double gd_168;
double gd_176;
double gd_184;
double gd_192;
double gd_200;
double gd_208;
double gd_216;
double gd_224;
double gd_232;
double gd_240;
double gd_248;
double gd_256;
double gd_264;
double gd_272;
double gd_280;
double gd_288;
double gd_296;
double gd_304;
double gd_312;
double gd_328;
double gd_336;
double gd_344;
double gd_352;
double gd_360;
double gd_368;
double gd_376;
double gd_384;
double gd_392;
double gd_400;
double gd_408;
double gd_416;
double gd_424;
double gd_432;

int init() {
   IndicatorBuffers(3);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(0, g_ibuf_92);
   SetIndexBuffer(1, g_ibuf_96);
   SetIndexBuffer(2, g_ibuf_100);
   SetIndexEmptyValue(0, 0.0);
   SetIndexEmptyValue(1, 0.0);
   SetIndexEmptyValue(2, 0.0);
   IndicatorShortName("FXProIndicator");
   SetIndexDrawBegin(0, Bars - gi_80);
   SetIndexDrawBegin(1, Bars - gi_80);
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
   if (gi_76 - 1 >= 5) gi_112 = gi_76 - 1;
   else gi_112 = 5;
   gd_424 = 3 / (gi_76 + 2.0);
   gd_432 = 1.0 - gd_424;
   return (0);
}

int start() {
   double ld_0 = Low[iLowest(Symbol(), 0, MODE_LOW, 4, 1)] - 1.0 * Point;
   double ld_8 = High[iHighest(Symbol(), 0, MODE_HIGH, 4, 1)] + 1.0 * Point;
   double ld_16 = 1.0 * AccountEquity() / 100.0 / ((ld_8 - Bid) / Point * MarketInfo(Symbol(), MODE_TICKVALUE));
   double ld_24 = 1.0 * AccountEquity() / 100.0 / ((Ask - ld_0) / Point * MarketInfo(Symbol(), MODE_TICKVALUE));
   Comment("FXProIndicator\n", "Stop Loss for Long Trades: ", ld_0, 
      "\nStop Loss for Short Trades: ", ld_8, 
      "\nTrade Size for Long Trades: ", ld_24, 
   "\nTrade Size for Short Trades: ", ld_16);
   g_ind_counted_120 = IndicatorCounted();
   if (g_ind_counted_120 < 0) return (-1);
   if (g_ind_counted_120 > gi_76) gi_104 = Bars - g_ind_counted_120 - 1;
   else gi_104 = Bars - gi_76 - 1;
   g_time_132 = Time[gi_104 + 1];
   if (g_time_132 != g_time_124 && gi_104 < Bars - gi_76 - 1) {
      if (g_time_132 == g_time_128) {
         gd_328 = gd_216;
         gd_336 = gd_224;
         gd_344 = gd_232;
         gd_352 = gd_240;
         gd_360 = gd_248;
         gd_368 = gd_256;
         gd_376 = gd_264;
         gd_384 = gd_272;
         gd_392 = gd_280;
         gd_400 = gd_288;
         gd_408 = gd_296;
         gd_416 = gd_304;
      } else return (-1);
   }
   if (gi_76 - 1 >= 5) gi_112 = gi_76 - 1;
   else gi_112 = 5;
   gd_424 = 3 / (gi_76 + 2.0);
   gd_432 = 1.0 - gd_424;
   while (gi_104 >= 0) {
      if (g_count_108 == 0) {
         g_count_108 = 1;
         gi_116 = FALSE;
      } else {
         if (g_count_108 >= gi_112) g_count_108 = gi_112 + 1;
         else g_count_108++;
         gd_144 = Close[gi_104] - (Close[gi_104 + 1]);
         gd_200 = MathAbs(gd_144);
         gd_328 = gd_432 * gd_328 + gd_424 * gd_144;
         gd_336 = gd_424 * gd_328 + gd_432 * gd_336;
         gd_184 = 1.5 * gd_328 - gd_336 / 2.0;
         gd_344 = gd_432 * gd_344 + gd_424 * gd_184;
         gd_352 = gd_424 * gd_344 + gd_432 * gd_352;
         gd_152 = 1.5 * gd_344 - gd_352 / 2.0;
         gd_360 = gd_432 * gd_360 + gd_424 * gd_152;
         gd_368 = gd_424 * gd_360 + gd_432 * gd_368;
         gd_160 = 1.5 * gd_360 - gd_368 / 2.0;
         gd_376 = gd_432 * gd_376 + gd_424 * gd_200;
         gd_384 = gd_424 * gd_376 + gd_432 * gd_384;
         gd_168 = 1.5 * gd_376 - gd_384 / 2.0;
         gd_392 = gd_432 * gd_392 + gd_424 * gd_168;
         gd_400 = gd_424 * gd_392 + gd_432 * gd_400;
         gd_192 = 1.5 * gd_392 - gd_400 / 2.0;
         gd_408 = gd_432 * gd_408 + gd_424 * gd_192;
         gd_416 = gd_424 * gd_408 + gd_432 * gd_416;
         gd_176 = 1.5 * gd_408 - gd_416 / 2.0;
         if (g_count_108 <= gi_112 && gd_144 != 0.0) gi_116 = TRUE;
         if (g_count_108 == gi_112 && gi_116 == FALSE) g_count_108 = 0;
      }
      if (g_count_108 > gi_112 && gd_176 > 0.0000000001) {
         gd_136 = 50.0 * (gd_160 / gd_176 + 1.0);
         if (gd_136 > 100.0) gd_136 = 100.0;
         if (gd_136 < 0.0) gd_136 = 0.0;
      } else gd_136 = 50.0;
      gd_312 = 100.0 * (gd_136 / 50.0 - 1.0);
      if (gi_104 == 1) {
         g_time_128 = Time[1];
         g_time_124 = Time[0];
         gd_216 = gd_328;
         gd_224 = gd_336;
         gd_232 = gd_344;
         gd_240 = gd_352;
         gd_248 = gd_360;
         gd_256 = gd_368;
         gd_264 = gd_376;
         gd_272 = gd_384;
         gd_280 = gd_392;
         gd_288 = gd_400;
         gd_296 = gd_408;
         gd_304 = gd_416;
      }
      gd_208 = gd_312 - (g_ibuf_92[gi_104 + 1]) - (g_ibuf_96[gi_104 + 1]) - (g_ibuf_100[gi_104 + 1]);
      g_ibuf_92[gi_104] = 0.0;
      g_ibuf_96[gi_104] = 0.0;
      g_ibuf_100[gi_104] = 0.0;
      if (gd_208 > 0.0) {
         g_ibuf_92[gi_104] = gd_312;
         if (g_ibuf_96[gi_104 + 1] != 0.0) g_ibuf_92[gi_104 + 1] = g_ibuf_92[gi_104];
      } else {
         if (gd_208 < 0.0) {
            g_ibuf_96[gi_104] = gd_312;
            if (g_ibuf_92[gi_104 + 1] != 0.0) g_ibuf_96[gi_104 + 1] = g_ibuf_96[gi_104];
         } else g_ibuf_100[gi_104] = gd_312;
      }
      gi_104--;
   }
   if (g_ibuf_92[1] != 0.0 && g_ibuf_96[2] != 0.0 && High[0] == Low[0] && High[0] == Close[0] && High[0] == Low[0]) {
      if (soundAlerts) Alert("FXPROIndicator: Long trade at " + Symbol());
      if (emailAlerts) SendMail("FXPROIndicator: Long trade at " + Symbol() + "!", "Long trade at " + Symbol());
   }
   if (g_ibuf_96[1] != 0.0 && g_ibuf_92[2] != 0.0 && High[0] == Low[0] && High[0] == Close[0] && High[0] == Low[0]) {
      if (soundAlerts) Alert("FXPROIndicator: Short trade at " + Symbol());
      if (emailAlerts) SendMail("FXPROIndicator: Short trade at " + Symbol() + "!", "Short trade in at " + Symbol());
   }
   return (0);
}
