Navigation:Home > Content >

FFRPremiumEA(EURCHF).mq4

Time: 2014-04-19 | Download file:FFRPremiumEA(EURCHF).mq4

/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: ht TP :// W wW .ME Ta qu OTE S . neT
   E-mail :  S UP [email protected] eT a q uO t e S. n et
*/

#import "FFRPremiumEA.dll"
   bool Activate(string a0, string a1, string a2, int a3, string a4, int a5, string a6, string a7);
   void GetLastErrorDescription(string a0);
   double func101(double a0);
   double func102(double a0, int a1);
   double func103(double a0, int a1);
   double func104(double a0, double a1);
   double func105(double a0, double a1);
   double func106(double a0, double a1);
#import

string Gs_76 = "1.0";
extern string License = "";
bool Gi_92 = FALSE;
bool Gi_96 = FALSE;
string Gs_100;
int Gi_108;
double Gd_112 = 0.0;
double Gd_120 = 0.0;
double Gd_128 = 0.0;
double Gd_136 = 0.0;
double G_period_144 = 0.0;
double G_period_152 = 0.0;
extern string EURCHF = "---------- EURCHF ----------";
extern int MagicNumber = 88888881;
extern int Hour_Start_Trade = 0;
extern int Hour_Stop_Trade = 1;
int Gi_180 = 50;
extern string Lots_Parameters = "---------- Lots - Parameters ----------";
extern double Lots = 0.01;
extern bool LotsOptimized = TRUE;
extern int Risk = 5;
extern int Maximum_Lots = 100;
extern string Order_Parameters = "---------- Order - Parameters ----------";
extern double StopLoss = 500.0;
extern double TakeProfit = 60.0;
extern bool Virtual_TP = FALSE;
extern int slippage = 4;
extern int slippage_close = 4;
extern double MaxSpread = 5.0;
extern bool Time_Opened_Protection = TRUE;
int Gi_260 = 60;
int Gi_264 = 3;
int Gi_268 = 140;
int Gi_272 = 2;
int Gi_276 = 170;
int Gi_280 = 0;
int Gi_284 = 200;
int Gi_288 = 1;
int Gi_292 = 240;
int Gi_296 = 4;
extern string Volatility_Parameters = "---------- Volatility - Parameters ----------";
extern bool Volatility_Filter = FALSE;
extern double sec = 0.001;
extern double se2c = 0.001;
extern double se3c = 0.0012;
double G_timeframe_336 = 15.0;
bool Gi_344 = TRUE;
bool Gi_348 = TRUE;
double G_minlot_352 = 0.0;
double G_maxlot_360 = 0.0;
int Gi_368 = 0;
int G_leverage_372 = 0;
double G_lots_376;
int G_ticket_384;
int G_count_388;

// 75BC773B15FA0B4BB9F62750119790C5
string f0_1() {
   return (StringConcatenate("v=", Gs_76, "&", "b=", AccountCompany()));
}

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   if (IsDemo()) Gi_108 = 1;
   else Gi_108 = 2;
   if (AccountNumber() == 0) {
      Gi_92 = TRUE;
      return (0);
   }
   Gi_96 = Activate(TerminalPath(), "" + AccountNumber(), AccountName(), Gi_108, License, 2, "FFRPremiumEA(EURCHF).ex4", f0_1());
   if (Gi_96) {
      Print("FFRPremiumEA License Activated");
      Comment("FFRPremiumEA License Activated");
   }
   Gs_100 = "123345345345353454364564564564646f34565465464564564564645645646464645645645646464564612313131313131313133343333333333333333333333333333333eeeeeeeeeeeeeeddddddddddddddddddddddddddddddddddddddqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwwewewewewewewewwwwwwwe1";
   GetLastErrorDescription(Gs_100);
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int order_total_0;
   double price_60;
   if (Gi_92) {
      if (AccountNumber() == 0) {
         Comment("Connecting to license server...");
         return (0);
      }
      Gi_92 = FALSE;
      if (IsDemo()) Gi_108 = 1;
      else Gi_108 = 2;
      Gi_96 = Activate(TerminalPath(), "" + AccountNumber(), AccountName(), Gi_108, License, 2, "FFRPremiumEA(EURCHF).ex4", f0_1());
      if (Gi_96) {
         Print("FFRPremiumEA License Activated");
         Comment("FFRPremiumEA License Activated");
      }
      Gs_100 = "123345345345353454364564564564646f34565465464564564564645645646464645645645646464564612313131313131313133343333333333333333333333333333333eeeeeeeeeeeeeeddddddddddddddddddddddddddddddddddddddqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwwewewewewewewewwwwwwwe1";
      GetLastErrorDescription(Gs_100);
   }
   if (Gi_96 == FALSE) {
      Comment(Gs_100);
      return (0);
   }
   Gd_112 = func101(Close[0]);
   Gd_120 = func102(Close[0], Hour_Start_Trade);
   Gd_128 = func103(Open[0], Hour_Stop_Trade);
   Gd_136 = func104(Open[0], Lots);
   G_period_144 = func105(Close[0], MaxSpread);
   G_period_152 = func106(StopLoss, TakeProfit);
   Comment("  ---   Server Time = ", TimeToStr(TimeCurrent(), TIME_MINUTES));
   if (Symbol() != "EURCHF" && Symbol() != "EURCHFm") return;
   double price_4 = TakeProfit;
   if (Virtual_TP == TRUE) {
      for (int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++) {
         OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber) {
            if (Bid >= OrderOpenPrice() + TakeProfit * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Virtual TP - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber) {
            if (Ask <= OrderOpenPrice() - TakeProfit * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
      }
   }
   if (Time_Opened_Protection == TRUE) {
      for (int pos_16 = 0; pos_16 < OrdersTotal(); pos_16++) {
         OrderSelect(pos_16, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber) {
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_260 && TimeCurrent() - OrderOpenTime() < 60 * Gi_268 && Bid >= OrderOpenPrice() + Gi_264 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_268 && TimeCurrent() - OrderOpenTime() < 60 * Gi_276 && Bid >= OrderOpenPrice() + Gi_272 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_276 && TimeCurrent() - OrderOpenTime() < 60 * Gi_284 && Bid >= OrderOpenPrice() - Gi_280 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_284 && TimeCurrent() - OrderOpenTime() < 60 * Gi_292 && Bid >= OrderOpenPrice() - Gi_288 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_292 && Bid >= OrderOpenPrice() - Gi_296 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, slippage_close, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber) {
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_260 && TimeCurrent() - OrderOpenTime() < 60 * Gi_268 && Ask <= OrderOpenPrice() - Gi_264 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_268 && TimeCurrent() - OrderOpenTime() < 60 * Gi_276 && Ask <= OrderOpenPrice() - Gi_272 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_276 && TimeCurrent() - OrderOpenTime() < 60 * Gi_284 && Ask <= OrderOpenPrice() + Gi_280 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_284 && TimeCurrent() - OrderOpenTime() < 60 * Gi_292 && Ask <= OrderOpenPrice() + Gi_288 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * Gi_292 && Ask <= OrderOpenPrice() + Gi_296 * Point) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, slippage_close, Orange);
               Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), 4) + " Lots : " + DoubleToStr(OrderLots(), 2) + " Order Number : " + DoubleToStr(OrderTicket(),
                  0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2));
            }
         }
      }
   }
   if (Volatility_Filter == TRUE) {
      if (iOpen(Symbol(), PERIOD_M5, 0) >= Ask + sec) return;
      if (iOpen(Symbol(), PERIOD_M5, 0) <= Bid - sec) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) >= Ask + se2c) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) <= Bid - se2c) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) >= Ask + se3c) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) <= Bid - se3c) return;
   }
   if (Ask - Bid > MaxSpread / 10000.0) return (0);
   G_minlot_352 = MarketInfo(Symbol(), MODE_MINLOT);
   G_maxlot_360 = MarketInfo(Symbol(), MODE_MAXLOT);
   G_leverage_372 = AccountLeverage();
   Gi_368 = MarketInfo(Symbol(), MODE_LOTSIZE);
   G_lots_376 = MathMin(G_maxlot_360, MathMax(G_minlot_352, Lots));
   if (LotsOptimized && Risk > 0.0) G_lots_376 = MathMax(G_minlot_352, MathMin(G_maxlot_360, NormalizeDouble(Risk / 100.0 * AccountFreeMargin() / G_minlot_352 / (Gi_368 / 100), 0) * G_minlot_352));
   G_lots_376 = MathMax(G_minlot_352, MathMin(G_maxlot_360, NormalizeDouble(G_lots_376 / G_minlot_352, 0) * G_minlot_352));
   G_lots_376 = NormalizeDouble(G_lots_376, 2);
   if (AccountFreeMargin() < Ask * G_lots_376 * Gi_368 / G_leverage_372) {
      Print("Low Account Balance. Lots = ", G_lots_376, " , Free Margin = ", AccountFreeMargin());
      Comment("Low Account Balance. Lots = ", G_lots_376, " , Free Margin = ", AccountFreeMargin());
      return;
   }
   if (G_lots_376 > Maximum_Lots) G_lots_376 = Maximum_Lots;
   double irsi_20 = iRSI(NULL, G_timeframe_336, G_period_152, PRICE_CLOSE, 0);
   double irsi_28 = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0);
   double ima_36 = iMA(NULL, 0, G_period_144, 0, MODE_SMA, PRICE_MEDIAN, 1);
   double ima_44 = iMA(NULL, 0, G_period_144, 0, MODE_SMA, PRICE_MEDIAN, 1);
   int count_52 = 0;
   for (int pos_56 = OrdersTotal() - 1; pos_56 >= 0; pos_56--) {
      OrderSelect(pos_56, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) count_52++;
   }
   if (count_52 == 0 && f0_2()) {
      order_total_0 = OrdersTotal();
      price_60 = Ask - StopLoss * Point;
      if (DayOfWeek() == 0 || DayOfWeek() == 5) return (0);
      if (DayOfWeek() == 1 && Hour() < Hour_Start_Trade) return (0);
      if ((!f0_0()) && irsi_20 < Gd_112 || irsi_28 < 36.0 && ima_36 >= Ask + 0.0002) {
         if (Gi_344) {
            if ((!Virtual_TP) && TakeProfit > 0.0) price_4 = Ask + TakeProfit * Point;
            else price_4 = 0;
            if (StopLoss > 0.0) price_60 = Ask - StopLoss * Point;
            else price_60 = 0;
            G_ticket_384 = -1;
            G_count_388 = 0;
            while (G_ticket_384 < 0) {
               if (G_count_388 > 0) Sleep(180000);
               G_count_388++;
               if ((!IsTradeAllowed()) || IsTradeContextBusy()) {
                  while (true) {
                     Sleep(5000);
                     if (!IsTradeAllowed() || IsTradeContextBusy()) continue;
                     break;
                  }
               }
               RefreshRates();
               G_ticket_384 = OrderSend(Symbol(), OP_BUY, G_lots_376, Ask, slippage, 0, 0, "Forex Robot", MagicNumber, 0, Green);
               if (G_count_388 == 10) {
                  Print("10 attempts to Open Buy trade have failed");
                  break;
               }
            }
            if (G_ticket_384 > 0) {
               if (OrderSelect(G_ticket_384, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice());
            } else Print("Error opening BUY order : ", GetLastError());
            order_total_0 = OrdersTotal();
            for (pos_12 = 0; pos_12 < order_total_0; pos_12++) {
               OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
               if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
                  if (IsTradeContextBusy() || (!IsTradeAllowed())) {
                     Print("Trade context is busy! The expert cannot modify Buy position!");
                     return (-1);
                  }
                  OrderModify(OrderTicket(), OrderOpenPrice(), price_60, price_4, 0, GreenYellow);
               }
            }
            Gi_344 = FALSE;
            Gi_348 = TRUE;
         }
      } else {
         if ((!f0_0()) && irsi_20 > Gd_120 || irsi_28 > 64.0 && ima_44 <= Bid - 0.0002) {
            if (Gi_348) {
               if ((!Virtual_TP) && TakeProfit > 0.0) price_4 = Bid - TakeProfit * Point;
               else price_4 = 0;
               if (StopLoss > 0.0) price_60 = Bid + StopLoss * Point;
               else price_60 = 0;
               G_ticket_384 = -1;
               G_count_388 = 0;
               while (G_ticket_384 < 0) {
                  if (G_count_388 > 0) Sleep(180000);
                  G_count_388++;
                  if ((!IsTradeAllowed()) || IsTradeContextBusy()) {
                     while (true) {
                        Sleep(5000);
                        if (!IsTradeAllowed() || IsTradeContextBusy()) continue;
                        break;
                     }
                  }
                  RefreshRates();
                  G_ticket_384 = OrderSend(Symbol(), OP_SELL, G_lots_376, Bid, slippage, 0, 0, "Forex Robot", MagicNumber, 0, Red);
                  if (G_count_388 == 10) {
                     Print("10 attempts to open Sell trade have failed");
                     break;
                  }
               }
               if (G_ticket_384 > 0) {
                  if (OrderSelect(G_ticket_384, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice());
               } else Print("Error opening SELL order : ", GetLastError());
               pos_56 = OrdersTotal();
               for (pos_12 = 0; pos_12 < pos_56; pos_12++) {
                  OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
                  if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
                     if (IsTradeContextBusy() || (!IsTradeAllowed())) {
                        Print("Trade context is busy! The expert cannot modify Sell position!");
                        return (-1);
                     }
                     OrderModify(OrderTicket(), OrderOpenPrice(), price_60, price_4, 0, GreenYellow);
                  }
               }
               Gi_348 = FALSE;
               Gi_344 = TRUE;
            }
         }
         if (irsi_20 < Gd_136 && irsi_20 > Gd_128) {
            Gi_348 = TRUE;
            Gi_344 = TRUE;
         }
      }
   }
   return (0);
}

// A88FE8FAEB651132C0CA6446B53FDF9B
int f0_2() {
   if (Hour_Start_Trade < Hour_Stop_Trade && TimeHour(TimeCurrent()) < Hour_Start_Trade || TimeHour(TimeCurrent()) >= Hour_Stop_Trade) return (0);
   if (Hour_Start_Trade > Hour_Stop_Trade && (TimeHour(TimeCurrent()) < Hour_Start_Trade && TimeHour(TimeCurrent()) >= Hour_Stop_Trade)) return (0);
   if (Hour_Stop_Trade == 0) Hour_Stop_Trade = 24;
   if (Hour() == Hour_Stop_Trade - 1 && Minute() >= Gi_180) return (0);
   return (1);
}

// 3070E883A104FCC047A1A6B240434873
bool f0_0() {
   bool Li_ret_0 = FALSE;
   for (int pos_4 = 0; pos_4 < OrdersTotal(); pos_4++) {
      if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               Li_ret_0 = TRUE;
               break;
            }
         }
      }
   }
   return (Li_ret_0);
}

Recommend