Navigation:Home > Content >

Nano_Test_EA.mq4

Time: 2011-06-28 | Download file:Nano_Test_EA.mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.438.1 [-]
   Website: https://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2011, Eugene Tetzlaff"
#property link      "http://www.metaquotes.net/"

//#include 
#import "stdlib.ex4"
   string ErrorDescription(int a0);
#import

extern string I09 = "- - - - - - - - - - Trade Settings - - - - - - - - - -";
extern bool TradeLive = TRUE;
extern int MagicNumber = 0;
extern string TradeComment = "";
extern double Lot = 0.01;
extern int slippage = 4;
extern int TakeProfitPips = 0;
extern int StopLossPips = 100;
extern string BE1 = "- - - - - - Break Even and Jumping Stop settings - - - - - -";
extern string BE2 = "- - - - -  Set JumpingStopPips to zero to disable JS - - - -";
extern int BreakEvenPips = 25;
extern int BreakEvenProfit = 10;
extern int JumpingStopPips = 1;
extern string TH2 = "- - - - - - - - - -Trading hours - - - - - - - - - -";
extern string TH3 = "- Use 24 hour, local computer time clock -";
extern string TH5 = "- - - - - - - - - Morning Hours 0-12 - - - - - - - -";
extern int start_hourm = 0;
extern int end_hourm = 12;
extern string TH6 = "- - - - - - - - - Evening Hours 12-24 - - - - - - -";
extern int start_houre = 12;
extern int end_houre = 24;
extern string M2 = "* * * * * * * * * * Misc Settings * * * * * * * * * *";
extern bool ShowPivotLines = TRUE;
extern string EML = "- - - - - - email must be set up in MT4  - - - - - -";
extern bool SendEmail = FALSE;
extern bool AlarmSoundOn = FALSE;
extern string SRN = "- - - - - - - - Screen Capture Settings - - - - - - - -";
extern bool AlarmScrnCapOn = TRUE;
extern int ScreenH = 1680;
extern int ScreenV = 1050;
int gi_244 = 10;
double gd_248 = 4.0;
double gd_256 = 15.0;
int g_ticket_264;
int g_count_268;
bool gi_272;
double gd_276;
double gd_284;
double gd_292;
double gd_300;
double gd_308;
bool gi_324 = TRUE;
bool g_bool_328 = TRUE;
int g_digits_332;
int gi_unused_336;
double gd_356;
double gd_364;
double gd_372;
double gd_380;
bool gi_388;
int gi_392;
int gi_396;
int gi_400;
int gi_404;
int gi_408;
int gi_416;
double gd_420;
double gd_428;
double gd_436;
double gd_444;
double g_price_476;
double g_price_484;
double g_price_508;
double g_price_516;
double g_price_524;
double g_price_532;
double g_price_540;
double g_price_548;
double g_price_556;
double g_price_564;
double g_price_572;
double g_price_580;
double g_price_588;
double g_price_596;
string gs_604;
string gs_612;
string gs_620;
string gs_unused_628;
int gi_636;

int init() {
   int li_0;
   f0_6();
   gd_380 = TimeCurrent();
   gi_272 = TRUE;
   gi_408 = 0;
   gi_396 = 0;
   gi_400 = 0;
   gi_404 = 0;
   if (Digits == 2 || Digits == 4) li_0 = 1;
   if (Digits == 3 || Digits == 5) li_0 = 10;
   if (Digits == 6) li_0 = 100;
   if (Digits == 7) li_0 = 1000;
   gi_unused_336 = li_0;
   gd_364 = MarketInfo(Symbol(), MODE_POINT);
   g_digits_332 = MarketInfo(Symbol(), MODE_DIGITS);
   if (g_digits_332 == 3 || g_digits_332 == 5) gd_364 = 10.0 * gd_364;
   slippage *= li_0;
   TakeProfitPips *= li_0;
   StopLossPips *= li_0;
   BreakEvenPips *= li_0;
   BreakEvenProfit *= li_0;
   JumpingStopPips *= li_0;
   f0_2();
   gs_604 = StringSubstr(Symbol(), 0, 3);
   gs_612 = StringSubstr(Symbol(), 3, 3);
   gs_620 = StringSubstr(Symbol(), 0, 6);
   gi_416 = 0;
   if (gs_620 == "NZDCAD") gi_416 = 1;
   if (gs_620 == "AUDUSD") gi_416 = 1;
   if (gs_620 == "EURCHF") gi_416 = 1;
   if (gs_620 == "EURGBP") gi_416 = 1;
   if (gs_620 == "AUDNZD") gi_416 = 2;
   if (gs_620 == "NZDUSD") gi_416 = 2;
   if (gs_620 == "CHFJPY") gi_416 = 2;
   if (gs_620 == "AUDCAD") gi_416 = 2;
   if (gs_620 == "USDCAD") gi_416 = 2;
   if (gs_620 == "NZDJPY") gi_416 = 3;
   if (gs_620 == "AUDCHF") gi_416 = 3;
   if (gs_620 == "AUDJPY") gi_416 = 3;
   if (gs_620 == "USDJPY") gi_416 = 3;
   if (gs_620 == "EURUSD") gi_416 = 3;
   if (gs_620 == "NZDCHF") gi_416 = 3;
   if (gs_620 == "CADCHF") gi_416 = 3;
   if (gs_620 == "GBPJPY") gi_416 = 4;
   if (gs_620 == "GBPCHF") gi_416 = 4;
   if (gs_620 == "CADJPY") gi_416 = 4;
   if (gs_620 == "EURCAD") gi_416 = 4;
   if (gs_620 == "EURAUD") gi_416 = 4;
   if (gs_620 == "USDCHF") gi_416 = 4;
   if (gs_620 == "GBPUSD") gi_416 = 4;
   if (gs_620 == "EURJPY") gi_416 = 4;
   if (gs_620 == "GBPNZD") gi_416 = 5;
   if (gs_620 == "EURNZD") gi_416 = 5;
   if (gs_620 == "GBPAUD") gi_416 = 5;
   if (gs_620 == "GBPCAD") gi_416 = 5;
   if (Period() == PERIOD_M1) gs_unused_628 = "M1";
   if (Period() == PERIOD_M5) gs_unused_628 = "M5";
   if (Period() == PERIOD_M15) gs_unused_628 = "M15";
   if (Period() == PERIOD_M30) gs_unused_628 = "M30";
   if (Period() == PERIOD_H1) gs_unused_628 = "H1";
   if (Period() == PERIOD_H4) gs_unused_628 = "H4";
   if (Period() == PERIOD_D1) gs_unused_628 = "D1";
   if (Period() == PERIOD_W1) gs_unused_628 = "W1";
   if (Period() == 40320) gs_unused_628 = "MN";
   return (0);
}

int deinit() {
   f0_6();
   Comment("");
   return (0);
}

void f0_20() {
   f0_16();
}

void f0_16() {
   bool bool_0;
   int error_4;
   double price_12;
   double price_20;
   double price_28;
   double price_36;
   for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {
      OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
         price_12 = OrderOpenPrice() + BreakEvenProfit * Point;
         price_20 = OrderOpenPrice() - BreakEvenProfit * Point;
         price_28 = OrderStopLoss() + JumpingStopPips * Point;
         price_36 = OrderStopLoss() - JumpingStopPips * Point;
         if (OrderType() == OP_BUY && Bid >= OrderOpenPrice() + Point * BreakEvenPips && OrderStopLoss() != price_12 && OrderStopLoss() < OrderOpenPrice()) {
            if (OrderStopLoss() >= OrderOpenPrice()) break;
            while (IsTradeContextBusy()) Sleep(100);
            bool_0 = OrderModify(OrderTicket(), OrderOpenPrice(), price_12, OrderTakeProfit(), 0, CLR_NONE);
            Alert("Breakeven set on ", OrderSymbol(), " ", price_12, " ", " ticket no ", OrderTicket());
            Print("Breakeven set on ", OrderSymbol(), " ticket no ", OrderTicket());
            if (!bool_0) {
               error_4 = GetLastError();
               Alert("Setting of breakeven SL ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
               Print("Setting of breakeven SL ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
            }
         }
         if (OrderType() == OP_BUY && JumpingStopPips > 0 && Bid >= OrderStopLoss() + (Point * BreakEvenPips + Point * JumpingStopPips) && OrderStopLoss() >= OrderOpenPrice()) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_0 = OrderModify(OrderTicket(), OrderOpenPrice(), price_28, OrderTakeProfit(), 0, CLR_NONE);
            Alert("Jumping Stop set at ", price_28, " on", OrderSymbol(), " ticket no ", OrderTicket());
            Print("Jumping Stop set at ", price_28, " on", OrderSymbol(), " ticket no ", OrderTicket());
            if (!bool_0) {
               error_4 = GetLastError();
               Alert("Setting of Jumping Stop loss ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
               Print("Setting of Jumping Stop loss ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
            }
         }
         if (OrderType() == OP_SELL && Ask <= OrderOpenPrice() - Point * BreakEvenPips && OrderStopLoss() != price_20 && OrderStopLoss() > OrderOpenPrice()) {
            if (OrderStopLoss() <= OrderOpenPrice()) break;
            while (IsTradeContextBusy()) Sleep(100);
            bool_0 = OrderModify(OrderTicket(), OrderOpenPrice(), price_20, OrderTakeProfit(), 0, CLR_NONE);
            Alert("Breakeven set on ", OrderSymbol(), " ", price_20, " ", " ticket no ", OrderTicket());
            Print("Breakeven set on ", OrderSymbol(), " ticket no ", OrderTicket());
            if (!bool_0) {
               error_4 = GetLastError();
               Alert("Setting of breakeven SL ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
               Print("Setting of breakeven SL ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
            }
         }
         if (OrderType() == OP_SELL && JumpingStopPips > 0 && Ask <= OrderStopLoss() - (Point * BreakEvenPips + Point * JumpingStopPips) && OrderStopLoss() <= OrderOpenPrice()) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_0 = OrderModify(OrderTicket(), OrderOpenPrice(), price_36, OrderTakeProfit(), 0, CLR_NONE);
            Alert("Jumping Stop set at ", price_36, " on", OrderSymbol(), " ticket no ", OrderTicket());
            Print("Jumping Stop set at ", price_36, " on", OrderSymbol(), " ticket no ", OrderTicket());
            if (!bool_0) {
               error_4 = GetLastError();
               Alert("Setting of Jumping Stop Loss ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
               Print("Setting of Jumping Stop Loss ", OrderSymbol(), " ticket no ", OrderTicket(), " failed with error (", error_4, "): ", ErrorDescription(error_4));
            }
         }
      }
   }
}

int f0_21(int a_cmd_0, string a_comment_4, double a_lots_12, double a_price_20, double a_price_28, double a_price_36) {
   int ticket_56;
   bool bool_60;
   int error_64;
   string ls_68;
   color color_44 = Red;
   bool li_48 = TRUE;
   if (a_cmd_0 == OP_BUY || a_cmd_0 == OP_BUYSTOP) color_44 = Green;
   int datetime_52 = 0;
   while (IsTradeContextBusy()) f0_23(gd_248, gd_256);
   if (!li_48) ticket_56 = OrderSend(Symbol(), a_cmd_0, a_lots_12, a_price_20, slippage, a_price_28, a_price_36, a_comment_4, MagicNumber, datetime_52, color_44);
   if (li_48) {
      while (IsTradeContextBusy()) f0_23(gd_248, gd_256);
      ticket_56 = OrderSend(Symbol(), a_cmd_0, a_lots_12, a_price_20, slippage, 0, 0, a_comment_4, MagicNumber, datetime_52, color_44);
      if (ticket_56 > 0) {
         if (a_price_36 > 0.0 && a_price_28 > 0.0) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_60 = OrderModify(ticket_56, OrderOpenPrice(), a_price_28, a_price_36, OrderExpiration(), CLR_NONE);
            if (!bool_60) {
               error_64 = GetLastError();
               Print(Symbol(), " SL/TP  order modify failed with error(", error_64, "): ", ErrorDescription(error_64));
            }
         }
         if (a_price_36 == 0.0 && a_price_28 == 0.0) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_60 = OrderModify(ticket_56, OrderOpenPrice(), a_price_28, a_price_36, OrderExpiration(), CLR_NONE);
            if (!bool_60) {
               error_64 = GetLastError();
               Print(Symbol(), " SL/TP  order modify failed with error(", error_64, "): ", ErrorDescription(error_64));
            }
         }
         if (a_price_36 != 0.0 && a_price_28 == 0.0) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_60 = OrderModify(ticket_56, OrderOpenPrice(), OrderStopLoss(), a_price_36, OrderExpiration(), CLR_NONE);
            if (!bool_60) {
               error_64 = GetLastError();
               Print(Symbol(), " SL  order modify failed with error(", error_64, "): ", ErrorDescription(error_64));
            }
         }
         if (a_price_36 == 0.0 && a_price_28 != 0.0) {
            while (IsTradeContextBusy()) Sleep(100);
            bool_60 = OrderModify(ticket_56, OrderOpenPrice(), a_price_28, OrderTakeProfit(), OrderExpiration(), CLR_NONE);
            if (!bool_60) {
               error_64 = GetLastError();
               Print(Symbol(), " SL  order modify failed with error(", error_64, "): ", ErrorDescription(error_64));
            }
         }
      }
   }
   if (ticket_56 < 0) {
      if (a_cmd_0 == OP_BUY) ls_68 = "OP_BUY";
      if (a_cmd_0 == OP_SELL) ls_68 = "OP_SELL";
      if (a_cmd_0 == OP_BUYLIMIT) ls_68 = "OP_BUYLIMIT";
      if (a_cmd_0 == OP_SELLLIMIT) ls_68 = "OP_SELLLIMIT";
      if (a_cmd_0 == OP_BUYSTOP) ls_68 = "OP_BUYSTOP";
      if (a_cmd_0 == OP_SELLSTOP) ls_68 = "OP_SELLSTOP";
      error_64 = GetLastError();
      Alert(Symbol(), " ", ls_68, " order send failed with error(", error_64, "): ", ErrorDescription(error_64));
      Print(Symbol(), " ", ls_68, " order send failed with error(", error_64, "): ", ErrorDescription(error_64));
      gi_272 = FALSE;
      return (0);
   }
   g_ticket_264 = ticket_56;
   f0_5(ticket_56);
   if (a_cmd_0 == OP_BUY) {
      if (AlarmScrnCapOn == TRUE) WindowScreenShot(Symbol() + Month() + "-" + Day() + "---" + Hour() + "-" + Minute() + ".gif", ScreenH, ScreenV);
      Alert(Symbol() + " Robot has sent a Buy Signal and suspended Robot");
      if (SendEmail == TRUE) SendMail("Trade Alert", "Robot Buy Alert on " + Symbol());
      if (AlarmSoundOn == TRUE) PlaySound("alert.wav");
   }
   if (a_cmd_0 == OP_SELL) {
      if (AlarmScrnCapOn == TRUE) WindowScreenShot(Symbol() + Month() + "-" + Day() + "---" + Hour() + "-" + Minute() + ".gif", ScreenH, ScreenV);
      Alert(Symbol() + " Robot has sent a Sell Signal and suspended Robot");
      if (SendEmail == TRUE) SendMail("Trade Alert", "Robot Sell Alert on " + Symbol());
      if (AlarmSoundOn == TRUE) PlaySound("alert.wav");
   }
   gi_272 = TRUE;
   return (1);
}

int f0_11() {
   g_ticket_264 = -1;
   if (OrdersTotal() == 0) return (0);
   for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
      if (OrderSelect(pos_0, SELECT_BY_POS)) {
         if (OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) {
            g_ticket_264 = OrderTicket();
            return (1);
         }
      }
   }
   return (0);
}

int f0_0() {
   if (gi_272) return (0);
   gi_404 = 1;
   if (gi_272 != FALSE) gi_404 = 0;
   if (gi_408 != 1) gi_404 = 0;
   if (TradeLive == FALSE) gi_404 = 0;
   if (gi_404 == 0) return (0);
   return (1);
}

int f0_10() {
   if (gi_272) return (0);
   gi_404 = 2;
   if (gi_272 != FALSE) gi_404 = 0;
   if (gi_408 != 2) gi_404 = 0;
   if (TradeLive == FALSE) gi_404 = 0;
   if (gi_404 == 0) return (0);
   return (1);
}

void f0_1() {
   gi_396 = 0;
   double ima_0 = iMA(NULL, PERIOD_H4, 5, 1, MODE_LWMA, PRICE_OPEN, 0);
   double ima_8 = iMA(NULL, PERIOD_D1, 5, 1, MODE_LWMA, PRICE_OPEN, 0);
   double ima_16 = iMA(NULL, PERIOD_H4, 5, 3, MODE_LWMA, PRICE_OPEN, 0);
   double ima_24 = iMA(NULL, PERIOD_D1, 5, 3, MODE_LWMA, PRICE_OPEN, 0);
   double ima_32 = iMA(NULL, PERIOD_H4, 5, 5, MODE_LWMA, PRICE_OPEN, 0);
   double ima_40 = iMA(NULL, PERIOD_D1, 5, 5, MODE_LWMA, PRICE_OPEN, 0);
   if (Bid > ima_0 && ima_0 > ima_16 && ima_16 > ima_32 && Bid > ima_8 && ima_8 > ima_24 && ima_24 > ima_40) gi_396 = 1;
   if (Bid < ima_0 && ima_0 < ima_16 && ima_16 < ima_32 && Bid < ima_8 && ima_8 < ima_24 && ima_24 < ima_40) gi_396 = 2;
}

void f0_22() {
   gi_400 = 0;
   if (gd_420 >= 0.4 && gd_428 >= 0.4) gi_400 = 1;
   if (gd_420 <= -0.4 && gd_428 <= -0.4) gi_400 = 2;
}

double f0_26(int a_timeframe_0, int ai_4) {
   double ld_24;
   double ld_32;
   double ld_8 = iATR(NULL, a_timeframe_0, 100, ai_4 + 10) / 10.0;
   double ld_unused_16 = 0.0;
   if (ld_8 != 0.0) {
      ld_24 = f0_8(a_timeframe_0, ai_4);
      ld_32 = f0_8(a_timeframe_0, ai_4 + 1);
      gd_428 = (ld_24 - ld_32) / ld_8;
   }
   return (gd_428);
}

double f0_19(int a_timeframe_0, int ai_4) {
   double ld_24;
   double ld_32;
   double ld_8 = iATR(NULL, a_timeframe_0, 100, ai_4 + 10) / 10.0;
   double ld_unused_16 = 0.0;
   if (ld_8 != 0.0) {
      ld_24 = f0_8(a_timeframe_0, ai_4);
      ld_32 = f0_8(a_timeframe_0, ai_4 + 1);
      gd_420 = (ld_24 - ld_32) / ld_8;
   }
   return (gd_420);
}

double f0_8(int a_timeframe_0, int ai_4) {
   double ld_8 = 21.0 * iClose(NULL, a_timeframe_0, ai_4);
   double ld_16 = 21;
   int li_24 = 1;
   for (int li_28 = 20; li_24 <= 20; li_28--) {
      ld_8 += li_28 * iClose(NULL, a_timeframe_0, ai_4 + li_24);
      ld_16 += li_28;
      if (li_24 <= ai_4) {
         ld_8 += li_28 * iClose(NULL, a_timeframe_0, ai_4 - li_24);
         ld_16 += li_28;
      }
      li_24++;
   }
   return (ld_8 / ld_16);
}

void f0_17() {
   gd_436 = 0;
   double ima_0 = iMA(NULL, PERIOD_W1, 2, 1, MODE_LWMA, PRICE_OPEN, 0);
   double ima_8 = iMA(NULL, PERIOD_H4, 1, 0, MODE_SMA, PRICE_MEDIAN, 0);
   if (ima_8 > ima_0) gd_436 = 1;
   if (ima_0 > ima_8) gd_436 = 2;
}

void f0_9() {
   gd_444 = 0;
   double ima_0 = iMA(NULL, PERIOD_W1, 1, 0, MODE_SMA, PRICE_OPEN, 0);
   double ima_8 = iMA(NULL, PERIOD_H4, 1, 0, MODE_SMA, PRICE_MEDIAN, 0);
   if (ima_8 > ima_0) gd_444 = 1;
   if (ima_0 > ima_8) gd_444 = 2;
}

void f0_12() {
   double ihigh_0 = iHigh(NULL, PERIOD_W1, 1);
   double ilow_8 = iLow(NULL, PERIOD_W1, 1);
   double iclose_16 = iClose(NULL, PERIOD_W1, 1);
   g_price_476 = (ihigh_0 + ilow_8 + iclose_16) / 3.0;
   g_price_508 = 2.0 * g_price_476 - ilow_8;
   g_price_532 = 2.0 * g_price_476 - ihigh_0;
   g_price_516 = g_price_476 + (ihigh_0 - ilow_8);
   g_price_540 = g_price_476 - (ihigh_0 - ilow_8);
   g_price_524 = 2.0 * g_price_476 + (ihigh_0 - 2.0 * ilow_8);
   g_price_548 = 2.0 * g_price_476 - (2.0 * ihigh_0 - ilow_8);
   double ihigh_24 = iHigh(NULL, PERIOD_MN1, 1);
   double ilow_32 = iLow(NULL, PERIOD_MN1, 1);
   double iclose_40 = iClose(NULL, PERIOD_MN1, 1);
   g_price_484 = (ihigh_24 + ilow_32 + iclose_40) / 3.0;
   g_price_556 = 2.0 * g_price_484 - ilow_32;
   g_price_580 = 2.0 * g_price_484 - ihigh_24;
   g_price_564 = g_price_484 + (ihigh_24 - ilow_32);
   g_price_588 = g_price_484 - (ihigh_24 - ilow_32);
   g_price_572 = 2.0 * g_price_484 + (ihigh_24 - 2.0 * ilow_32);
   g_price_596 = 2.0 * g_price_484 - (2.0 * ihigh_24 - ilow_32);
}

void f0_18() {
   ObjectDelete("PivotW");
   ObjectCreate("PivotW", OBJ_TREND, 0, Time[5], g_price_476, Time[0], g_price_476);
   ObjectSet("PivotW", OBJPROP_RAY, FALSE);
   ObjectSet("PivotW", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("PivotW", OBJPROP_COLOR, SkyBlue);
   ObjectSet("PivotW", OBJPROP_WIDTH, 3);
   ObjectDelete("R1W");
   ObjectCreate("R1W", OBJ_TREND, 0, Time[5], g_price_508, Time[0], g_price_508);
   ObjectSet("R1W", OBJPROP_RAY, FALSE);
   ObjectSet("R1W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("R1W", OBJPROP_COLOR, Red);
   ObjectSet("R1W", OBJPROP_WIDTH, 1);
   ObjectDelete("R2W");
   ObjectCreate("R2W", OBJ_TREND, 0, Time[5], g_price_516, Time[0], g_price_516);
   ObjectSet("R2W", OBJPROP_RAY, FALSE);
   ObjectSet("R2W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("R2W", OBJPROP_COLOR, Red);
   ObjectSet("R2W", OBJPROP_WIDTH, 1);
   ObjectDelete("R3W");
   ObjectCreate("R3W", OBJ_TREND, 0, Time[5], g_price_524, Time[0], g_price_524);
   ObjectSet("R3W", OBJPROP_RAY, FALSE);
   ObjectSet("R3W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("R3W", OBJPROP_COLOR, Red);
   ObjectSet("R3W", OBJPROP_WIDTH, 1);
   ObjectDelete("S1W");
   ObjectCreate("S1W", OBJ_TREND, 0, Time[5], g_price_532, Time[0], g_price_532);
   ObjectSet("S1W", OBJPROP_RAY, FALSE);
   ObjectSet("S1W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("S1W", OBJPROP_COLOR, Green);
   ObjectSet("S1W", OBJPROP_WIDTH, 1);
   ObjectDelete("S2W");
   ObjectCreate("S2W", OBJ_TREND, 0, Time[5], g_price_540, Time[0], g_price_540);
   ObjectSet("S2W", OBJPROP_RAY, FALSE);
   ObjectSet("S2W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("S2W", OBJPROP_COLOR, Green);
   ObjectSet("S2W", OBJPROP_WIDTH, 1);
   ObjectDelete("S3W");
   ObjectCreate("S3W", OBJ_TREND, 0, Time[5], g_price_548, Time[0], g_price_548);
   ObjectSet("S3W", OBJPROP_RAY, FALSE);
   ObjectSet("S3W", OBJPROP_STYLE, STYLE_DOT);
   ObjectSet("S3W", OBJPROP_COLOR, Green);
   ObjectSet("S3W", OBJPROP_WIDTH, 1);
   ObjectDelete("PivotM");
   ObjectCreate("PivotM", OBJ_TREND, 0, Time[23], g_price_484, Time[0], g_price_484);
   ObjectSet("PivotM", OBJPROP_RAY, FALSE);
   ObjectSet("PivotM", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("PivotM", OBJPROP_COLOR, Blue);
   ObjectSet("PivotM", OBJPROP_WIDTH, 3);
   ObjectDelete("R1M");
   ObjectCreate("R1M", OBJ_TREND, 0, Time[23], g_price_556, Time[0], g_price_556);
   ObjectSet("R1M", OBJPROP_RAY, FALSE);
   ObjectSet("R1M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("R1M", OBJPROP_COLOR, Red);
   ObjectSet("R1M", OBJPROP_WIDTH, 4);
   ObjectDelete("R2M");
   ObjectCreate("R2M", OBJ_TREND, 0, Time[23], g_price_564, Time[0], g_price_564);
   ObjectSet("R2M", OBJPROP_RAY, FALSE);
   ObjectSet("R2M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("R2M", OBJPROP_COLOR, Red);
   ObjectSet("R2M", OBJPROP_WIDTH, 4);
   ObjectDelete("R3M");
   ObjectCreate("R3M", OBJ_TREND, 0, Time[23], g_price_572, Time[0], g_price_572);
   ObjectSet("R3M", OBJPROP_RAY, FALSE);
   ObjectSet("R3M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("R3M", OBJPROP_COLOR, Red);
   ObjectSet("R3M", OBJPROP_WIDTH, 4);
   ObjectDelete("S1M");
   ObjectCreate("S1M", OBJ_TREND, 0, Time[23], g_price_580, Time[0], g_price_580);
   ObjectSet("S1M", OBJPROP_RAY, FALSE);
   ObjectSet("S1M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("S1M", OBJPROP_COLOR, Green);
   ObjectSet("S1M", OBJPROP_WIDTH, 4);
   ObjectDelete("S2M");
   ObjectCreate("S2M", OBJ_TREND, 0, Time[23], g_price_588, Time[0], g_price_588);
   ObjectSet("S2M", OBJPROP_RAY, FALSE);
   ObjectSet("S2M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("S2M", OBJPROP_COLOR, Green);
   ObjectSet("S2M", OBJPROP_WIDTH, 4);
   ObjectDelete("S3M");
   ObjectCreate("S3M", OBJ_TREND, 0, Time[23], g_price_596, Time[0], g_price_596);
   ObjectSet("S3M", OBJPROP_RAY, FALSE);
   ObjectSet("S3M", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("S3M", OBJPROP_COLOR, Green);
   ObjectSet("S3M", OBJPROP_WIDTH, 4);
}

void f0_13() {
   gi_408 = 0;
   double iclose_0 = iClose(NULL, PERIOD_H4, 1);
   double iclose_8 = iClose(NULL, PERIOD_D1, 1);
   if (gi_400 == 1 && gi_396 == 1 && iclose_0 > g_price_476 && iclose_8 > g_price_484 && gd_436 == 1.0 && gd_444 == 1.0) gi_408 = 1;
   if (gi_400 == 2 && gi_396 == 2 && iclose_0 < g_price_476 && iclose_8 < g_price_484 && gd_436 == 2.0 && gd_444 == 2.0) gi_408 = 2;
}

void f0_15() {
   double ld_0;
   double ld_8;
   double price_16;
   bool li_24;
   bool li_28;
   int li_40;
   RefreshRates();
   bool li_32 = f0_0();
   bool li_36 = f0_10();
   if (li_32) {
      RefreshRates();
      li_24 = FALSE;
      price_16 = Ask;
      if (StopLossPips > 0) ld_8 = NormalizeDouble(Bid - StopLossPips * Point, Digits);
      else ld_8 = 0;
      if (TakeProfitPips > 0) ld_0 = NormalizeDouble(Ask + TakeProfitPips * Point, Digits);
      else ld_0 = 0;
      li_28 = TRUE;
   }
   if (li_36) {
      RefreshRates();
      li_24 = TRUE;
      price_16 = Bid;
      if (StopLossPips > 0) ld_8 = NormalizeDouble(Ask + StopLossPips * Point, Digits);
      else ld_8 = 0;
      if (TakeProfitPips > 0) ld_0 = NormalizeDouble(Bid - TakeProfitPips * Point, Digits);
      else ld_0 = 0;
      li_28 = TRUE;
   }
   if (li_28) {
      gd_356 = Lot;
      li_40 = f0_21(li_24, TradeComment, gd_356, price_16, ld_8, ld_0);
   }
   if (li_28 && li_40) {
   }
   if (li_28 && (!li_40)) {
   }
}

void f0_25() {
   int datetime_44;
   double ld_48;
   gd_276 = 0;
   gd_284 = 0;
   gd_292 = 0;
   gd_300 = 0;
   gd_308 = 0;
   int datetime_0 = iTime(Symbol(), PERIOD_H1, 0);
   int datetime_4 = iTime(Symbol(), PERIOD_D1, 0);
   int datetime_8 = iTime(Symbol(), PERIOD_W1, 0);
   int datetime_12 = iTime(Symbol(), PERIOD_MN1, 0);
   int li_16 = 3600;
   int li_20 = 24 * li_16;
   int li_24 = 7 * li_20;
   int li_28 = 31 * li_20;
   int datetime_32 = TimeCurrent();
   int hist_total_36 = OrdersHistoryTotal();
   for (int pos_40 = 0; pos_40 <= hist_total_36; pos_40++) {
      if (OrderSelect(pos_40, SELECT_BY_POS, MODE_HISTORY)) {
         datetime_44 = OrderOpenTime();
         ld_48 = OrderProfit() + OrderSwap();
         if (OrderSymbol() != Symbol() && gi_324) continue;
         if (datetime_44 >= datetime_0) gd_284 += ld_48;
         if (datetime_44 >= datetime_4) gd_292 += ld_48;
         if (datetime_44 >= datetime_8) gd_300 += ld_48;
         if (datetime_44 >= datetime_12) gd_308 += ld_48;
      }
   }
   for (pos_40 = 0; pos_40 <= OrdersTotal(); pos_40++) {
      if (OrderSelect(pos_40, SELECT_BY_POS, MODE_TRADES)) {
         ld_48 = OrderProfit() + OrderSwap();
         if (OrderSymbol() != Symbol() && gi_324) continue;
         gd_276 += ld_48;
      }
   }
}

void f0_3() {
   gd_372 = NormalizeDouble((Ask - Bid) / gd_364, 1);
}

void f0_4() {
   int li_0 = 15;
   int li_unused_4 = 125;
   f0_14("PRICED", 40, li_0, 0);
   ObjectSetText("PRICED", DoubleToStr(Bid, 5), 20, "Courier", Yellow);
   li_0 += 35;
   if (gi_408 == 1) {
      f0_14("BUYER", 70, li_0, 0);
      ObjectSetText("BUYER", "Buy Alert", 10, "Arial Bold", Lime);
   }
   if (gi_408 == 2) {
      f0_14("BUYER", 70, li_0, 0);
      ObjectSetText("BUYER", "Sell Alert", 10, "Arial Bold", Red);
   }
   if (gi_408 == 0) {
      f0_14("BUYER", 70, li_0, 0);
      ObjectSetText("BUYER", "No Alert", 10, "Arial Bold", Gray);
   }
   li_0 += 20;
   f0_14("Comment12A", 60, li_0, 0);
   if (g_bool_328 == TRUE) ObjectSetText("Comment12A", "Within Hours", 8, "Arial Bold", Orange);
   if (g_bool_328 == FALSE) ObjectSetText("Comment12A", "Outside Hours", 8, "Arial Bold", Gray);
   li_0 += 15;
   if (gi_272 == FALSE) {
      f0_14("Comment2A", 57, li_0, 0);
      ObjectSetText("Comment2A", "Robot Active ", 8, "Arial Bold", Orange);
   }
   if (gi_272 == TRUE) {
      f0_14("Comment2A", 45, li_0, 0);
      ObjectSetText("Comment2A", " Robot Suspended  ", 8, "Arial Bold", Gray);
   }
   if (gi_272 == TRUE || g_bool_328 == FALSE || TradeLive == FALSE) {
      f0_14("Comment2A", 45, li_0, 0);
      ObjectSetText("Comment2A", "Trading Suspended ", 8, "Arial Bold", Gray);
   }
   li_0 += 15;
   f0_14("Comment12B", 25, li_0, 0);
   ObjectSetText("Comment12B", "", 8, "Arial Bold", Lime);
   if (gi_388 == TRUE && f0_11() == 1) ObjectSetText("Comment12B", "Buy Trade Open         ", 8, "Arial Bold", Lime);
   if (gi_392 == 2 && f0_11() == 1) ObjectSetText("Comment12B", "Sell Trade Open          ", 8, "Arial Bold", Red);
   li_0 += 20;
   f0_14("Comment3", 100, li_0, 0);
   ObjectSetText("Comment3", "Magic # : ", 8, "Arial Bold", Yellow);
   f0_14("Comment3A", 50, li_0, 0);
   ObjectSetText("Comment3A", DoubleToStr(MagicNumber, 0), 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("Comment4", 100, li_0, 0);
   ObjectSetText("Comment4", "Lot : ", 8, "Arial Bold", Yellow);
   f0_14("Comment4A", 50, li_0, 0);
   ObjectSetText("Comment4A", DoubleToStr(Lot, 2), 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("Comment5", 100, li_0, 0);
   ObjectSetText("Comment5", "Spread : ", 8, "Arial Bold", Yellow);
   f0_14("Comment5A", 50, li_0, 0);
   ObjectSetText("Comment5A", DoubleToStr(gd_372, 1), 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("BEJS", 100, li_0, 0);
   ObjectSetText("BEJS", "BE / JS: ", 8, "Arial Bold", Yellow);
   f0_14("BEJSA", 40, li_0, 0);
   ObjectSetText("BEJSA", DoubleToStr(BreakEvenPips / 10, 0) + " / " + DoubleToStr(BreakEvenProfit / 10, 0) + " / " + DoubleToStr(JumpingStopPips / 10, 0), 8, "Arial Bold",
      White);
   li_0 += 30;
   f0_14("Comment51", 100, li_0, 0);
   ObjectSetText("Comment51", "Slope H4 : ", 8, "Arial Bold", Gray);
   if (gd_428 > 0.4) ObjectSetText("Comment51", "Slope H4 : ", 8, "Arial Bold", Lime);
   if (gd_428 < -0.4) ObjectSetText("Comment51", "Slope H4 : ", 8, "Arial Bold", Red);
   f0_14("Comment51A", 50, li_0, 0);
   ObjectSetText("Comment51A", DoubleToStr(gd_428, 4), 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("Comment61", 100, li_0, 0);
   ObjectSetText("Comment61", "Slope D1 : ", 8, "Arial Bold", Gray);
   if (gd_420 > 0.4) ObjectSetText("Comment61", "Slope D1 : ", 8, "Arial Bold", Lime);
   if (gd_420 < -0.4) ObjectSetText("Comment61", "Slope D1 : ", 8, "Arial Bold", Red);
   f0_14("Comment61A", 50, li_0, 0);
   ObjectSetText("Comment61A", DoubleToStr(gd_420, 4), 8, "Arial Bold", White);
   li_0 += 20;
   f0_14("MaCross", 100, li_0, 0);
   ObjectSetText("MaCross", "Ma H4/D1 : ", 8, "Arial Bold", Gray);
   if (gi_396 == 1) ObjectSetText("MaCross", "Ma H4/D1 : ", 8, "Arial Bold", Lime);
   if (gi_396 == 2) ObjectSetText("MaCross", "Ma H4/D1 : ", 8, "Arial Bold", Red);
   f0_14("MaCrossA", 50, li_0, 0);
   if (gi_396 == 0) ObjectSetText("MaCrossA", "", 8, "Arial Bold", Black);
   if (gi_396 == 1) ObjectSetText("MaCrossA", "Buy", 8, "Arial Bold", White);
   if (gi_396 == 2) ObjectSetText("MaCrossA", "Sell", 8, "Arial Bold", White);
   li_0 += 20;
   f0_14("PivotWeekly", 100, li_0, 0);
   ObjectSetText("PivotWeekly", "Pivot W1: ", 8, "Arial Bold", Gray);
   if (Bid > g_price_476) ObjectSetText("PivotWeekly", "Pivot W1: ", 8, "Arial Bold", Lime);
   if (Bid < g_price_476) ObjectSetText("PivotWeekly", "Pivot W1: ", 8, "Arial Bold", Red);
   f0_14("PivotWeeklyA", 50, li_0, 0);
   ObjectSetText("PivotWeeklyA", DoubleToStr(g_price_476, 4), 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("PivotMonthly", 100, li_0, 0);
   ObjectSetText("PivotMonthly", "Pivot MN: ", 8, "Arial Bold", Gray);
   if (Bid > g_price_484) ObjectSetText("PivotMonthly", "Pivot MN: ", 8, "Arial Bold", Lime);
   if (Bid < g_price_484) ObjectSetText("PivotMonthly", "Pivot MN: ", 8, "Arial Bold", Red);
   f0_14("PivotMonthlyA", 50, li_0, 0);
   ObjectSetText("PivotMonthlyA", DoubleToStr(g_price_484, 4), 8, "Arial Bold", White);
   li_0 += 20;
   f0_14("WOH2x1UP", 100, li_0, 0);
   ObjectSetText("WOH2x1UP", "WOH2x1 W1: ", 8, "Arial Bold", Gray);
   if (gd_436 == 1.0) ObjectSetText("WOH2x1UP", "WOH2x1 W1: ", 8, "Arial Bold", Lime);
   if (gd_436 == 2.0) ObjectSetText("WOH2x1UP", "WOH2x1 W1: ", 8, "Arial Bold", Red);
   f0_14("WOH2x1UPA", 50, li_0, 0);
   if (gd_436 == 0.0) ObjectSetText("WOH2x1UPA", "", 8, "Arial Bold", Black);
   if (gd_436 == 1.0) ObjectSetText("WOH2x1UPA", "Buy", 8, "Arial Bold", White);
   if (gd_436 == 2.0) ObjectSetText("WOH2x1UPA", "Sell", 8, "Arial Bold", White);
   li_0 += 15;
   f0_14("WOH1x0UP", 100, li_0, 0);
   ObjectSetText("WOH1x0UP", "WOH1x0 W1: ", 8, "Arial Bold", Gray);
   if (gd_444 == 1.0) ObjectSetText("WOH1x0UP", "WOH1x0 W1: ", 8, "Arial Bold", Lime);
   if (gd_444 == 2.0) ObjectSetText("WOH1x0UP", "WOH1x0 W1: ", 8, "Arial Bold", Red);
   f0_14("WOH1x0UPA", 50, li_0, 0);
   if (gd_444 == 0.0) ObjectSetText("WOH1x0UPA", "", 8, "Arial Bold", Black);
   if (gd_444 == 1.0) ObjectSetText("WOH1x0UPA", "Buy", 8, "Arial Bold", White);
   if (gd_444 == 2.0) ObjectSetText("WOH1x0UPA", "Sell", 8, "Arial Bold", White);
   li_0 += 20;
   f0_14("GRP", 100, li_0, 0);
   ObjectSetText("GRP", "Group: ", 8, "Arial Bold", Orange);
   f0_14("GRPA", 65, li_0, 0);
   ObjectSetText("GRPA", DoubleToStr(gi_416, 0), 8, "Arial Bold", White);
   li_0 += 35;
   f0_14("Comment11A", 30, li_0, 0);
   if (gd_276 == 0.0) ObjectSetText("Comment11A", DoubleToStr(gd_276, 2), 12, "Arial Bold", Black);
   if (gd_276 > 0.0) ObjectSetText("Comment11A", DoubleToStr(gd_276, 2), 12, "Arial Bold", Lime);
   if (gd_276 < 0.0) ObjectSetText("Comment11A", DoubleToStr(gd_276, 2), 12, "Arial Bold", Red);
}

void f0_2() {
   if (TimeCurrent() >= gd_380) {
      f0_12();
      if (ShowPivotLines == TRUE) f0_18();
      f0_1();
      f0_26(PERIOD_H4, 0);
      f0_19(PERIOD_D1, 0);
      f0_22();
      f0_17();
      f0_9();
      gd_380 = TimeCurrent() + 600.0;
   }
   f0_3();
   f0_25();
   f0_13();
   f0_4();
}

int f0_24() {
   int li_0 = TimeHour(TimeLocal());
   if (end_hourm < start_hourm) end_hourm += 24;
   if (end_houre < start_houre) end_houre += 24;
   g_bool_328 = TRUE;
   g_bool_328 = (li_0 >= start_hourm && li_0 <= end_hourm) || (li_0 >= start_houre && li_0 <= end_houre);
   if (!g_bool_328 && li_0 < 12) {
      li_0 += 24;
      g_bool_328 = (li_0 >= start_hourm && li_0 <= end_hourm) || (li_0 >= start_houre && li_0 <= end_houre);
   }
   if (li_0 >= MathMax(end_hourm, end_houre)) g_bool_328 = FALSE;
   return (g_bool_328);
}

void f0_7() {
   g_count_268 = 0;
   g_ticket_264 = -1;
   if (OrdersTotal() != 0) {
      for (int pos_0 = 0; pos_0 <= OrdersTotal(); pos_0++) {
         if (OrderSelect(pos_0, SELECT_BY_POS)) {
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
               g_count_268++;
               g_ticket_264 = OrderTicket();
            }
         }
      }
   }
}

int f0_5(int ai_0) {
   int li_24;
   int ticket_4 = OrderTicket();
   int count_8 = 0;
   int error_12 = GetLastError();
   error_12 = 0;
   bool li_16 = FALSE;
   bool li_ret_20 = FALSE;
   while (!li_16) {
      li_24 = OrdersTotal();
      for (int pos_28 = 0; pos_28 < li_24; pos_28++) {
         if (OrderSelect(pos_28, SELECT_BY_POS, MODE_TRADES) == TRUE) {
            if (OrderTicket() == ai_0) {
               li_ret_20 = TRUE;
               li_16 = TRUE;
            }
         }
      }
      if (count_8 > 3) {
         li_24 = OrdersHistoryTotal();
         for (pos_28 = 0; pos_28 < li_24; pos_28++) {
            if (OrderSelect(pos_28, SELECT_BY_POS, MODE_HISTORY) == TRUE) {
               if (OrderTicket() == ai_0) {
                  li_ret_20 = TRUE;
                  li_16 = TRUE;
               }
            }
         }
      }
      count_8++;
      if (count_8 > gi_244) li_16 = TRUE;
      if (!(li_ret_20 || li_16)) {
         Print("Did not find #" + ai_0 + " in history, sleeping, then doing retry #" + count_8);
         f0_23(gd_248, gd_256);
      }
   }
   if (ticket_4 >= 0) OrderSelect(ticket_4, SELECT_BY_TICKET, MODE_TRADES);
   if (!li_ret_20) Print("Never found #" + ai_0 + " in history! crap!");
   return (li_ret_20);
}

void f0_23(double ad_0, double ad_8) {
   double ld_16;
   double ld_24;
   int li_32;
   if (IsTesting() == FALSE) {
      ld_16 = (MathRand() + 1) / 32768.0;
      ld_24 = (-MathLog(ld_16)) * ad_0;
      ld_24 = MathMin(ld_24, ad_8);
      li_32 = 1000.0 * ld_24;
      if (li_32 < 10) li_32 = 10;
      Sleep(li_32);
   }
}

int start() {
   f0_2();
   if (OrdersTotal() == 0) g_ticket_264 = -1;
   gi_388 = FALSE;
   gi_392 = 0;
   if (OrdersTotal() > 0) {
      f0_7();
      gi_636 = f0_11();
      if (gi_636 == 1) {
         if (OrderProfit() > 0.0) f0_20();
         if (OrderType() == OP_BUY) gi_388 = TRUE;
         if (OrderType() == OP_SELL) gi_392 = 2;
         gi_272 = TRUE;
      }
   }
   if (gd_420 < 0.4 && gd_428 < 0.4 && gd_420 > -0.4 && gd_428 > -0.4 && gi_388 == FALSE && gi_392 == 0 && gi_272 == TRUE) gi_272 = FALSE;
   int li_0 = f0_24();
   if (li_0) {
      if (g_ticket_264 != -1) return (0);
      f0_15();
   }
   return (0);
}

int f0_14(string a_name_0, int a_x_8, int a_y_12, int a_window_16) {
   ObjectCreate(a_name_0, OBJ_LABEL, a_window_16, 0, 0);
   ObjectSet(a_name_0, OBJPROP_CORNER, 1);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12);
   ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
   return (0);
}

void f0_6() {
   ObjectsDeleteAll(0, OBJ_LABEL);
}

Recommend