/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2010, ZeusFX Trading Solutions."
#property link      "http://www.zeusfx.com"

string gs_unused_76 = "Trend Configurations";
string gs_unused_84 = "Stochastic";
bool gi_92 = TRUE;
bool gi_96 = TRUE;
int g_timeframe_100 = PERIOD_M15;
int g_period_104 = 7;
int g_period_108 = 2;
int g_slowing_112 = 4;
int gi_116 = 60;
int gi_120 = 40;
bool gi_124 = TRUE;
bool gi_128 = TRUE;
int g_timeframe_132 = PERIOD_M5;
int g_period_136 = 5;
int g_period_140 = 2;
int g_slowing_144 = 4;
int gi_148 = 90;
int gi_152 = 10;
bool gi_156 = TRUE;
bool gi_160 = TRUE;
int g_timeframe_164 = PERIOD_M1;
int g_period_168 = 7;
int g_period_172 = 3;
int g_slowing_176 = 4;
int gi_180 = 70;
int gi_184 = 30;
string gs_unused_188 = "CCI";
bool gi_196 = TRUE;
bool gi_200 = TRUE;
int g_timeframe_204 = PERIOD_M5;
int g_period_208 = 14;
int gi_212 = 80;
int gi_216 = -80;
string gs_unused_220 = "Moving Average";
bool gi_228 = TRUE;
bool gi_232 = TRUE;
int g_timeframe_236 = PERIOD_H4;
int g_period_240 = 7;
int gi_244 = 0;
int g_ma_method_248 = MODE_SMA;
int gi_252 = 1;
bool gi_256 = TRUE;
bool gi_260 = TRUE;
int g_timeframe_264 = PERIOD_H1;
int g_period_268 = 150;
int gi_272 = 0;
int g_ma_method_276 = MODE_SMA;
int gi_280 = 1;
bool gi_284 = TRUE;
bool gi_288 = TRUE;
int g_timeframe_292 = PERIOD_H1;
int g_period_296 = 21;
int gi_300 = 0;
int g_ma_method_304 = MODE_SMA;
int gi_308 = 1;
bool gi_312 = TRUE;
bool gi_316 = TRUE;
int g_timeframe_320 = PERIOD_M30;
int g_period_324 = 14;
int gi_328 = 0;
int g_ma_method_332 = MODE_SMA;
int gi_336 = 1;
bool gi_340 = TRUE;
bool gi_344 = FALSE;
int g_timeframe_348 = PERIOD_M15;
int g_period_352 = 150;
int gi_356 = 0;
int g_ma_method_360 = MODE_SMA;
int gi_364 = 1;
string gs_unused_368 = "Range Detection";
bool gi_376 = TRUE;
bool gi_380 = TRUE;
int gi_384 = 60;
int gi_388 = 5;
int gi_392 = 20;
bool gi_396 = TRUE;
bool gi_400 = TRUE;
int gi_404 = 5;
int gi_408 = 30;
int gi_412 = 15;
int gi_416 = 70;

int init() {
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_0 = 0;
   if (li_0 == 1000) li_0 = OrderExport28("GBPUSD", 282828, 15, 15, 1, 1, 98, 4);
   if (li_0 == 1001) OrderVolumeA28(282828, 30, 10, 10, 1, 4);
   if (li_0 == 1002) OrderVolumeB28(282828, 30, 10, 10, 1, 4);
   return (0);
}

int OrderExport28(string a_symbol_0, int a_magic_8, int ai_12, int ai_16, int ai_20, int ai_24, int ai_28, int ai_32) {
   int li_52;
   int li_56;
   int li_60;
   bool li_72;
   bool li_76;
   bool li_80;
   double ld_100;
   double ld_108;
   double ld_116;
   double ld_148;
   double ld_164;
   int l_datetime_228;
   string l_symbol_36 = a_symbol_0;
   int l_pos_44 = 0;
   int li_unused_48 = 36;
   int l_count_64 = 0;
   int li_unused_68 = MarketInfo(a_symbol_0, MODE_SPREAD);
   bool li_84 = FALSE;
   int li_88 = 0;
   double ld_92 = PointNumbersC2(ai_32);
   double ld_124 = 0;
   double ld_156 = 0;
   double ld_172 = 0;
   double ld_204 = 0;
   double ld_212 = NormalizeDouble(MarketInfo(a_symbol_0, MODE_ASK), ai_32);
   double ld_220 = NormalizeDouble(MarketInfo(a_symbol_0, MODE_BID), ai_32);
   int l_datetime_232 = 0;
   li_88 = Hour() - ai_20;
   if (li_88 < 0) li_88 += 24;
   if (li_88 >= 24) li_88 -= 24;
   if (DayOfWeek() == 0 || (DayOfWeek() == 1 && TimeHour(TimeCurrent()) < ai_12 + ai_20) || (DayOfWeek() >= 5 && TimeHour(TimeCurrent()) > ai_16 + ai_20)) {
      li_72 = TRUE;
      li_76 = TRUE;
   }
   for (l_pos_44 = 0; l_pos_44 < OrdersTotal(); l_pos_44++) {
      OrderSelect(l_pos_44, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY && OrderSymbol() == a_symbol_0) li_52++;
      if (OrderType() == OP_SELL && OrderSymbol() == a_symbol_0) li_56++;
      if (OrderType() == OP_BUY) ld_100 = OrderLots() + ld_100;
      if (OrderType() == OP_SELL) ld_108 = OrderLots() + ld_108;
      if (OrderMagicNumber() == a_magic_8) {
         if (OrderType() == OP_BUY && OrderOpenTime() >= l_datetime_228) {
            l_datetime_228 = OrderOpenTime();
            ld_164 = NormalizeDouble(OrderOpenPrice(), ai_32);
         }
         if (OrderType() == OP_BUY) {
            ld_148 = OrderProfit() + ld_148;
            li_60++;
         }
         if (OrderType() == OP_SELL && OrderOpenTime() >= l_datetime_232) {
            l_datetime_232 = OrderOpenTime();
            ld_172 = NormalizeDouble(OrderOpenPrice(), ai_32);
         }
         if (OrderType() == OP_SELL) {
            ld_156 = OrderProfit() + ld_156;
            l_count_64++;
         }
      }
   }
   double l_istochastic_236 = iStochastic(Symbol(), g_timeframe_100, g_period_104, g_period_108, g_slowing_112, MODE_SMA, 1, MODE_SIGNAL, 0);
   double l_istochastic_244 = iStochastic(Symbol(), g_timeframe_132, g_period_136, g_period_140, g_slowing_144, MODE_SMA, 1, MODE_SIGNAL, 0);
   double l_istochastic_252 = iStochastic(Symbol(), g_timeframe_164, g_period_168, g_period_172, g_slowing_176, MODE_SMA, 1, MODE_SIGNAL, 0);
   double l_icci_260 = iCCI(Symbol(), g_timeframe_204, g_period_208, PRICE_MEDIAN, 0);
   double l_ima_268 = iMA(Symbol(), g_timeframe_236, g_period_240, gi_244, g_ma_method_248, PRICE_LOW, 0);
   double l_ima_276 = iMA(Symbol(), g_timeframe_236, g_period_240, gi_244, g_ma_method_248, PRICE_LOW, 1);
   double l_ima_284 = iMA(Symbol(), g_timeframe_264, g_period_268, gi_272, g_ma_method_276, PRICE_LOW, 0);
   double l_ima_292 = iMA(Symbol(), g_timeframe_264, g_period_268, gi_272, g_ma_method_276, PRICE_LOW, 1);
   double l_ima_300 = iMA(Symbol(), g_timeframe_292, g_period_296, gi_300, g_ma_method_304, PRICE_LOW, 0);
   double l_ima_308 = iMA(Symbol(), g_timeframe_292, g_period_296, gi_300, g_ma_method_304, PRICE_LOW, 1);
   double l_ima_316 = iMA(Symbol(), g_timeframe_320, g_period_324, gi_328, g_ma_method_332, PRICE_LOW, 0);
   double l_ima_324 = iMA(Symbol(), g_timeframe_320, g_period_324, gi_328, g_ma_method_332, PRICE_LOW, 1);
   double l_ima_332 = iMA(Symbol(), g_timeframe_348, g_period_352, gi_356, g_ma_method_360, PRICE_LOW, 0);
   double l_ima_340 = iMA(Symbol(), g_timeframe_348, g_period_352, gi_356, g_ma_method_360, PRICE_LOW, 1);
   if ((gi_380 && li_60 >= 1) || (gi_376 && li_60 == 0) && RangeMarket(l_symbol_36, gi_384, gi_388, gi_392, ai_32) == 1) li_80 = TRUE;
   if ((gi_380 && l_count_64 >= 1) || (gi_376 && l_count_64 == 0) && RangeMarket(l_symbol_36, gi_384, gi_388, gi_392, ai_32) == 1) li_84 = TRUE;
   if ((gi_400 && li_60 >= 1) || (gi_396 && li_60 == 0) && RangeMarket(l_symbol_36, gi_404, gi_408, gi_412, ai_32) == 1) li_80 = TRUE;
   if ((gi_400 && l_count_64 >= 1) || (gi_396 && l_count_64 == 0) && RangeMarket(l_symbol_36, gi_404, gi_408, gi_412, ai_32) == 1) li_84 = TRUE;
   double ld_180 = ld_164 + gi_416 * ld_92;
   double ld_188 = ld_164 - gi_416 * ld_92;
   double ld_196 = ld_172 + gi_416 * ld_92;
   ld_204 = ld_172 - gi_416 * ld_92;
   if (ld_212 >= ld_188 && ld_212 <= ld_180) li_80 = TRUE;
   if (ld_212 <= ld_196 && ld_212 >= ld_204) li_84 = TRUE;
   if ((li_60 == 0 && gi_228 == TRUE) || (li_60 >= 1 && gi_232 == TRUE) && l_ima_268 > l_ima_276)
      if (l_ima_268 - l_ima_276 < gi_252 * ld_92 && ld_148 >= 0.0) li_80 = TRUE;
   if ((li_60 == 0 && gi_256 == TRUE) || (li_60 >= 1 && gi_260 == TRUE) && l_ima_284 > l_ima_292)
      if (l_ima_284 - l_ima_292 < gi_280 * ld_92 && ld_148 >= 0.0) li_80 = TRUE;
   if ((li_60 == 0 && gi_284 == TRUE) || (li_60 >= 1 && gi_288 == TRUE) && l_ima_300 > l_ima_308)
      if (l_ima_300 - l_ima_308 < gi_308 * ld_92 && ld_148 >= 0.0) li_80 = TRUE;
   if ((li_60 == 0 && gi_312 == TRUE) || (li_60 >= 1 && gi_316 == TRUE) && l_ima_316 > l_ima_324)
      if (l_ima_316 - l_ima_324 < gi_336 * ld_92 && ld_148 >= 0.0) li_80 = TRUE;
   if ((li_60 == 0 && gi_340 == TRUE) || (li_60 >= 1 && gi_344 == TRUE) && l_ima_332 > l_ima_340)
      if (l_ima_332 - l_ima_340 < gi_364 * ld_92 && ld_148 >= 0.0) li_80 = TRUE;
   if ((li_60 == 0 && gi_228 == TRUE) || (li_60 >= 1 && gi_232 == TRUE) && l_ima_268 < l_ima_276) li_80 = TRUE;
   if ((li_60 == 0 && gi_256 == TRUE) || (li_60 >= 1 && gi_260 == TRUE) && l_ima_284 < l_ima_292) li_80 = TRUE;
   if ((li_60 == 0 && gi_284 == TRUE) || (li_60 >= 1 && gi_288 == TRUE) && l_ima_300 < l_ima_308) li_80 = TRUE;
   if ((li_60 == 0 && gi_312 == TRUE) || (li_60 >= 1 && gi_316 == TRUE) && l_ima_316 < l_ima_324) li_80 = TRUE;
   if ((li_60 == 0 && gi_340 == TRUE) || (li_60 >= 1 && gi_344 == TRUE) && l_ima_332 < l_ima_340) li_80 = TRUE;
   if ((li_60 == 0 && gi_196 == TRUE) || (li_60 >= 1 && gi_200 == TRUE) && l_icci_260 > gi_216) li_80 = TRUE;
   if ((li_60 == 0 && gi_92 == TRUE) || (li_60 >= 1 && gi_96 == TRUE) && l_istochastic_236 > gi_120) li_80 = TRUE;
   if ((li_60 == 0 && gi_124 == TRUE) || (li_60 >= 1 && gi_128 == TRUE) && l_istochastic_244 > gi_152) li_80 = TRUE;
   if ((li_60 == 0 && gi_156 == TRUE) || (li_60 >= 1 && gi_160 == TRUE) && l_istochastic_252 > gi_184) li_80 = TRUE;
   if ((l_count_64 == 0 && gi_228 == TRUE) || (l_count_64 >= 1 && gi_232 == TRUE) && l_ima_268 < l_ima_276)
      if (l_ima_276 - l_ima_268 < gi_252 * ld_92 && ld_156 >= 0.0) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_256 == TRUE) || (l_count_64 >= 1 && gi_260 == TRUE) && l_ima_284 < l_ima_292)
      if (l_ima_292 - l_ima_284 < gi_280 * ld_92 && ld_156 >= 0.0) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_284 == TRUE) || (l_count_64 >= 1 && gi_288 == TRUE) && l_ima_300 < l_ima_308)
      if (l_ima_308 - l_ima_300 < gi_308 * ld_92 && ld_156 >= 0.0) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_312 == TRUE) || (l_count_64 >= 1 && gi_316 == TRUE) && l_ima_316 < l_ima_324)
      if (l_ima_324 - l_ima_316 < gi_336 * ld_92 && ld_156 >= 0.0) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_340 == TRUE) || (l_count_64 >= 1 && gi_344 == TRUE) && l_ima_332 < l_ima_340)
      if (l_ima_340 - l_ima_332 < gi_364 * ld_92 && ld_156 >= 0.0) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_228 == TRUE) || (l_count_64 >= 1 && gi_232 == TRUE) && l_ima_268 > l_ima_276) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_256 == TRUE) || (l_count_64 >= 1 && gi_260 == TRUE) && l_ima_284 > l_ima_292) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_284 == TRUE) || (l_count_64 >= 1 && gi_288 == TRUE) && l_ima_300 > l_ima_308) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_312 == TRUE) || (l_count_64 >= 1 && gi_316 == TRUE) && l_ima_316 > l_ima_324) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_340 == TRUE) || (l_count_64 >= 1 && gi_344 == TRUE) && l_ima_332 > l_ima_340) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_196 == TRUE) || (l_count_64 >= 1 && gi_200 == TRUE) && l_icci_260 < gi_212) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_92 == TRUE) || (l_count_64 >= 1 && gi_96 == TRUE) && l_istochastic_236 < gi_116) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_124 == TRUE) || (l_count_64 >= 1 && gi_128 == TRUE) && l_istochastic_244 < gi_148) li_84 = TRUE;
   if ((l_count_64 == 0 && gi_156 == TRUE) || (l_count_64 >= 1 && gi_160 == TRUE) && l_istochastic_252 < gi_180) li_84 = TRUE;
   if (ld_100 > 0.0 || ld_108 > 0.0) {
      if (li_80 == FALSE)
         if (AccountMargin() + 100000.0 * (ld_116 * ld_212) / AccountLeverage() >= AccountEquity() * ai_28 / 100.0 && ai_24 == 1) li_80 = TRUE;
      if (li_84 == FALSE)
         if (AccountMargin() + 100000.0 * (ld_124 * ld_220) / AccountLeverage() >= AccountEquity() * ai_28 / 100.0 && ai_24 == 1) li_84 = TRUE;
   }
   if (li_80 == TRUE || li_72 == TRUE && li_84 == TRUE || li_76 == TRUE) return (0);
   if (li_80 == TRUE || li_72 == TRUE && (li_84 == FALSE && li_76 == FALSE)) return (2);
   if (li_80 == FALSE && li_72 == FALSE && li_84 == TRUE || li_76 == TRUE) return (3);
   if (li_80 == FALSE && li_72 == FALSE && (li_84 == FALSE && li_76 == FALSE)) return (4);
   return (0);
}

double OrderVolumeA28(int a_magic_0, double ad_4, double ad_12, double ad_20, int ai_28, int ai_32) {
   double ld_36;
   double l_ord_lots_44 = 0;
   int l_datetime_52 = 0;
   double ld_56 = 5.03;
   double ld_64 = 50;
   double ld_72 = ad_12 * (ad_4 / 10.0) / ld_56;
   for (int l_pos_80 = 0; l_pos_80 < OrdersTotal(); l_pos_80++) {
      OrderSelect(l_pos_80, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == a_magic_0) {
         if (OrderType() == OP_BUY && OrderOpenTime() >= l_datetime_52) {
            l_datetime_52 = OrderOpenTime();
            ld_36 = NormalizeDouble(OrderOpenPrice(), ai_32);
            l_ord_lots_44 = OrderLots();
         }
      }
   }
   if (ld_72 > ad_20) ld_72 = ad_20;
   if (IsTesting()) {
      if (Year() == 2005) ld_72 = 45.59;
      if (Year() == 2006) ld_72 = 17.11;
      if (Year() == 2007) ld_72 = 9.94;
      if (Year() == 2008) ld_72 = 12.91;
      if (Year() == 2009) ld_72 = 5.96;
      if (Year() == 2010) ld_72 = 7.49;
   }
   double ld_ret_84 = NormalizeDouble(AccountBalance() * ld_72 / 100000.0, ai_28);
   if (ld_36 != 0.0) ld_ret_84 = NormalizeDouble(l_ord_lots_44 + l_ord_lots_44 * ld_64 / 100.0, ai_28);
   return (ld_ret_84);
}

double OrderVolumeB28(int a_magic_0, double ad_4, double ad_12, double ad_20, int ai_28, int ai_32) {
   double ld_36;
   double l_ord_lots_44 = 0;
   int l_datetime_52 = 0;
   double ld_56 = 5.03;
   double ld_64 = 50;
   double ld_72 = ad_12 * (ad_4 / 10.0) / ld_56;
   for (int l_pos_80 = 0; l_pos_80 < OrdersTotal(); l_pos_80++) {
      OrderSelect(l_pos_80, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == a_magic_0) {
         if (OrderType() == OP_SELL && OrderOpenTime() >= l_datetime_52) {
            l_datetime_52 = OrderOpenTime();
            ld_36 = NormalizeDouble(OrderOpenPrice(), ai_32);
            l_ord_lots_44 = OrderLots();
         }
      }
   }
   if (ld_72 > ad_20) ld_72 = ad_20;
   if (IsTesting()) {
      if (Year() == 2005) ld_72 = 45.59;
      if (Year() == 2006) ld_72 = 17.11;
      if (Year() == 2007) ld_72 = 9.94;
      if (Year() == 2008) ld_72 = 12.91;
      if (Year() == 2009) ld_72 = 5.96;
      if (Year() == 2010) ld_72 = 7.49;
   }
   double ld_ret_84 = NormalizeDouble(AccountBalance() * ld_72 / 100000.0, ai_28);
   if (ld_36 != 0.0) ld_ret_84 = NormalizeDouble(l_ord_lots_44 + l_ord_lots_44 * ld_64 / 100.0, ai_28);
   return (ld_ret_84);
}

double PointNumbersC2(int ai_0) {
   double ld_ret_4 = 1;
   int l_count_12 = 0;
   for (l_count_12 = 0; l_count_12 < ai_0; l_count_12++) ld_ret_4 /= 10.0;
   return (ld_ret_4);
}

int RangeMarket(string a_symbol_0, int a_timeframe_8, int ai_12, int ai_16, int ai_20) {
   double l_iclose_52;
   double l_iopen_60;
   bool li_ret_68;
   double ld_24 = PointNumbersC2(ai_20);
   double ld_32 = 0;
   double ld_40 = 1000;
   for (int li_48 = 0; li_48 < ai_12; li_48++) {
      l_iclose_52 = iClose(a_symbol_0, a_timeframe_8, li_48);
      l_iopen_60 = iOpen(a_symbol_0, a_timeframe_8, li_48);
      if (l_iclose_52 >= l_iopen_60 && l_iclose_52 > ld_32) ld_32 = l_iclose_52;
      if (l_iopen_60 >= l_iclose_52 && l_iopen_60 > ld_32) ld_32 = l_iopen_60;
      if (l_iclose_52 <= l_iopen_60 && l_iclose_52 < ld_40) ld_40 = l_iclose_52;
      if (l_iopen_60 <= l_iclose_52 && l_iopen_60 < ld_40) ld_40 = l_iopen_60;
   }
   if ((ld_32 - ld_40) / ld_24 <= ai_16) li_ret_68 = TRUE;
   else li_ret_68 = FALSE;
   return (li_ret_68);
}
