Navigation´╝ÜHome > Content >

MFM4.mq4

Time: 2012-12-24 | Download file:MFM4.mq4

#property copyright "Copyright 2013, MFM3.NET"
#property link      "http://www.mfm3.net"

//#include 
#import "stdlib.ex4"
   string IntegerToHexString(int a0); // 90267E7BE5477D1C3601D9A426F82FA1
#import "wininet.dll"
   int InternetOpenA(string a0, int a1, string a2, string a3, int a4);
   int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, int a5);
   int InternetReadFile(int a0, string a1, int a2, int& a3[]);
   int InternetCloseHandle(int a0);
   int InternetConnectA(int a0, string a1, int a2, string a3, string a4, int a5, int a6, int a7);
   bool HttpSendRequestA(int a0, string a1, int a2, int& a3[], int a4);
   bool HttpAddRequestHeadersA(int a0, string a1, int a2, int a3);
   int HttpOpenRequestA(int a0, string a1, string a2, string a3, string a4, string& a5[], int a6, int a7);
#import

int Gia_76[] = {33, 42, 39, 40, 41, 59, 58, 64, 38, 61, 43, 36, 47, 63, 35, 91, 93};
extern string Email;
extern string Password;
extern double Lot_Size = 0.0;
extern double Lot_Multiplier = 1.0;
extern string ADVANCED_SETTINGS_BELOW = "ADVANCED SETTING BELOW";
extern bool Download_Time_Offset = TRUE;
extern int Time_Offset = 0;
extern bool Download_Settings = TRUE;
extern int Take_Profit = 0;
extern int Stop_Loss = 0;
extern int Funky_Take = 20;
extern int Funky_Stop = 20;
extern int Entry_Size = 20;
extern int Frequency = 0;
extern int Double_Down = 0;
string Gs_160 = "There is no server comment.";
int G_magic_168 = 7171923;
int G_datetime_172;
int G_datetime_176;
int G_datetime_180;
int G_datetime_184;
bool Gi_188;
bool Gi_192;
double Gd_196;
bool Gi_204 = TRUE;
int Gi_208;

// AB2FC3C3886182B6A0B76424CB7612E5
int f0_18(string As_0, string &A_str_concat_8) {
   int Li_16 = InternetOpenA("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)", 0, "0", "0", 0);
   int Li_20 = InternetOpenUrlA(Li_16, As_0, "0", 0, -2080374528, 0);
   if (Li_20 == 0) return (0);
   int Lia_24[] = {1};
   string Ls_28 = "";
   while (true) {
      if (InternetReadFile(Li_20, Ls_28, 128, Lia_24) <= 0 || Lia_24[0] == 0) break;
      A_str_concat_8 = StringConcatenate(A_str_concat_8, StringSubstr(Ls_28, 0, Lia_24[0]));
   }
   InternetCloseHandle(Li_20);
   InternetCloseHandle(Li_16);
   return (1);
}

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   f0_10();
   start();
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   if (G_datetime_172 < iTime(Symbol(), PERIOD_H1, 0)) {
      f0_21();
      G_datetime_172 = iTime(Symbol(), PERIOD_H1, 0);
   }
   if (G_datetime_176 < iTime(Symbol(), PERIOD_M5, 0)) {
      f0_22();
      G_datetime_176 = iTime(Symbol(), PERIOD_M5, 0);
   }
   if (G_datetime_180 < iTime(Symbol(), PERIOD_M1, 0)) {
      f0_20();
      G_datetime_180 = iTime(Symbol(), PERIOD_M1, 0);
   }
   if (IsTesting()) {
      if (G_datetime_184 < iTime(Symbol(), PERIOD_M1, 0)) {
         f0_0();
         G_datetime_184 = iTime(Symbol(), PERIOD_M1, 0);
      }
   } else f0_0();
   return (0);
}

// DD3F965174E8BB2F64523981626CED1A
void f0_21() {
   Gi_208 = f0_2();
   Gd_196 = f0_1();
}

// E0B846401F21EF8503AB4BFA55649394
void f0_22() {
   if (!IsTesting()) f0_23();
}

// B24F6123111E5FD9D9444FCD337DCBD6
void f0_20() {
   f0_8();
}

// 0B3516A5BBB77566F904F9D3877F4710
void f0_0() {
   f0_14();
   f0_7();
   if (!IsTesting()) f0_16();
}

// 48076832DB453133C58AB5742B53253B
void f0_8() {
   if (Gi_208 == 17 || Gi_208 == 18) {
      Gi_192 = TRUE;
      return;
   }
   if (Time_Offset == 24) {
      Gi_192 = TRUE;
      return;
   }
   Gi_192 = FALSE;
}

// 75173CEBBCC36E16FC4BF1BF2DBC0FDF
void f0_14() {
   if (f0_11() == 0 && Gi_192 == TRUE && Ask <= iCustom(Symbol(), PERIOD_M5, "Bands", Entry_Size, 0, Frequency / 10.0, 1, 0)) {
      if (Gi_188 == TRUE) f0_15();
      if (Gi_188 == 2 && Download_Settings == FALSE) f0_15();
   }
   if (f0_11() == 1 && Double_Down != 0 && Gi_192 == FALSE && Ask < f0_13() - f0_19(Double_Down)) f0_15();
}

// 831A28F1E8DF07C553FCD59546465D13
void f0_15() {
   OrderSend(Symbol(), OP_BUY, f0_9(), Ask, 1, 0, 0, "MFM3", G_magic_168, 0, Blue);
   if (Take_Profit > 0) f0_17(f0_13() + f0_19(Take_Profit));
   if (Stop_Loss > 0) f0_4(f0_13() - f0_19(Stop_Loss));
}

// ACAF33542AC3FAEE9F459EC1746719E9
double f0_19(int Ai_0) {
   int Li_4 = 5;
   if (Digits == 2 || Digits == 4) Li_4 = 4;
   if (Li_4 == 5) return (Ai_0 * Point);
   if (Li_4 == 4) return (MathRound(Ai_0 / 10) * Point);
   return (0.0);
}

// EEFA40C5089C6AC3290FC768121AC7B8
void f0_23() {
   if (Gi_204 == TRUE && Gi_192 == TRUE) {
      f0_10();
      Gi_204 = FALSE;
   }
   if (Gi_204 == FALSE && Gi_192 == FALSE) Gi_204 = TRUE;
}

// 5A750F86EF41F22F852C43351E3FF383
void f0_10() {
   string str_concat_0;
   f0_18(StringConcatenate("https://www.mfm3.net/settings.php?email=", Email, "&password=", Password, "&pair=", Symbol(), "&skey=B7M1YD6BKS8", "&broker=", AccountNumber(),
      "&htime=", Hour(), "&settings=", Download_Settings), str_concat_0);
   Gi_188 = f0_5(1, 0, str_concat_0);
   if (IsTesting() && Download_Time_Offset == TRUE) Gi_188 = FALSE;
   if (Download_Settings == TRUE) {
      Double_Down = f0_5(4, 2, str_concat_0);
      Entry_Size = f0_5(2, 6, str_concat_0);
      Take_Profit = f0_5(3, 8, str_concat_0);
      Funky_Take = f0_5(2, 11, str_concat_0);
      Stop_Loss = f0_5(4, 13, str_concat_0);
      Funky_Stop = f0_5(2, 17, str_concat_0);
      Frequency = f0_5(2, 19, str_concat_0);
   }
   if (Download_Time_Offset == TRUE) Time_Offset = f0_5(2, 21, str_concat_0);
   Gs_160 = f0_3(23, str_concat_0);
}

// 21C1128497AF5A2C9AB4CB4582C9B3FC
string f0_3(int Ai_0, string As_4) {
   string str_concat_12;
   for (int count_20 = 0; count_20 < 255; count_20++) {
      if (StringGetChar(As_4, Ai_0) == 0) break;
      str_concat_12 = StringConcatenate(str_concat_12, CharToStr(StringGetChar(As_4, Ai_0)));
      Ai_0++;
   }
   return (str_concat_12);
}

// 3D398132638907170054A061B3D03392
int f0_5(int Ai_0, int Ai_4, string As_8) {
   string str_concat_16;
   for (int count_24 = 0; count_24 < Ai_0; count_24++) {
      str_concat_16 = StringConcatenate(str_concat_16, CharToStr(StringGetChar(As_8, Ai_4)));
      Ai_4++;
   }
   return (StrToInteger(str_concat_16));
}

// 46FA7A99C05665DB9FD37B897F8E2CEF
void f0_7() {
   if (Bid >= iCustom(Symbol(), PERIOD_M5, "Bands", Entry_Size, 0, Funky_Take / 10.0, 1, 0) && f0_12() >= 0.0 && Funky_Take != 0) f0_6();
   if (Bid >= iCustom(Symbol(), PERIOD_M15, "Bands", Funky_Stop, 0, 2.0, 1, 0) && f0_12() <= 0.0 && Funky_Stop != 0 && Gi_192 == FALSE) f0_6();
   if (f0_12() >= 0.0 && Gi_192 == FALSE) f0_6();
}

// 503878E5DF13DC2C7D5C888077C69572
double f0_9() {
   double Ld_ret_0 = f0_1();
   if (AccountFreeMargin() - MarketInfo(Symbol(), MODE_MARGINREQUIRED) * Ld_ret_0 >= 0.2 * AccountEquity()) return (Ld_ret_0);
   return (0);
}

// 0B6EA95BB493F742B192291704036600
double f0_1() {
   double Ld_0;
   if (MarketInfo(Symbol(), MODE_MINLOT) == 0.01) {
      if (Lot_Size == 0.0) Ld_0 = MathRound(AccountBalance() / 100.0 * Lot_Multiplier);
      if (Lot_Size != 0.0) Ld_0 = MathRound(100.0 * Lot_Size);
      if (Ld_0 < 1.0) Ld_0 = 1;
      return (Ld_0 / 100.0);
   }
   if (MarketInfo(Symbol(), MODE_MINLOT) == 0.1) {
      if (Lot_Size == 0.0) Ld_0 = MathRound(AccountBalance() / 1000.0 * Lot_Multiplier);
      if (Lot_Size != 0.0) Ld_0 = MathRound(10.0 * Lot_Size);
      if (Ld_0 < 1.0) Ld_0 = 1;
      return (Ld_0 / 10.0);
   }
   return (0);
}

// 69E090A48DA3C10E30BACB5A5EE32A02
double f0_12() {
   bool Li_ret_0 = FALSE;
   for (int pos_4 = 0; pos_4 <= OrdersTotal(); pos_4++) {
      OrderSelect(pos_4, SELECT_BY_POS);
      if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == G_magic_168) Li_ret_0 = Li_ret_0 + OrderProfit();
   }
   return (Li_ret_0);
}

// 68080E8DDEF46F84078D782C7A9E47C8
int f0_11() {
   int count_0 = 0;
   for (int pos_4 = 0; pos_4 <= OrdersTotal(); pos_4++) {
      OrderSelect(pos_4, SELECT_BY_POS);
      if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == G_magic_168) count_0++;
   }
   return (count_0);
}

// 703837B6F56975D74CA57750760F13C0
double f0_13() {
   double order_open_price_0 = 0;
   for (int pos_8 = 0; pos_8 <= OrdersTotal(); pos_8++) {
      OrderSelect(pos_8, SELECT_BY_POS);
      if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == G_magic_168 && order_open_price_0 == 0.0) order_open_price_0 = OrderOpenPrice();
      else
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && OrderMagicNumber() == G_magic_168 && OrderOpenPrice() > order_open_price_0) order_open_price_0 = OrderOpenPrice();
   }
   return (order_open_price_0);
}

// 88B19775A98EB05106184C877BC9F931
void f0_17(double A_price_0) {
   for (int pos_8 = 0; pos_8 <= OrdersTotal(); pos_8++) {
      OrderSelect(pos_8, SELECT_BY_POS);
      if (OrderMagicNumber() == G_magic_168 && OrderSymbol() == Symbol() && OrderType() == OP_BUY) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), A_price_0, 0, Blue);
   }
}

// 2F313CEFFF3D7A527DFC670C03C7A75F
void f0_4(double A_price_0) {
   for (int pos_8 = 0; pos_8 <= OrdersTotal(); pos_8++) {
      OrderSelect(pos_8, SELECT_BY_POS);
      if (OrderMagicNumber() == G_magic_168 && OrderSymbol() == Symbol() && OrderType() == OP_BUY) OrderModify(OrderTicket(), OrderOpenPrice(), A_price_0, OrderTakeProfit(), 0, Blue);
   }
}

// 45D2344FC4CCFE835137193C0845A365
void f0_6() {
   for (int pos_0 = 0; pos_0 <= OrdersTotal(); pos_0++) {
      OrderSelect(pos_0, SELECT_BY_POS);
      if (OrderMagicNumber() == G_magic_168 && OrderSymbol() == Symbol() && OrderType() == OP_BUY) {
         OrderClose(OrderTicket(), OrderLots(), Bid, 0, Blue);
         pos_0--;
      }
   }
}

// 8413C683B4B27CC3F4DBD4C90329D8BA
void f0_16() {
   string Ls_0;
   string Ls_8;
   string dbl2str_16;
   string dbl2str_24;
   string dbl2str_32;
   string dbl2str_40;
   string dbl2str_48;
   int Li_56;
   string Ls_60;
   if (Download_Settings == TRUE) Ls_0 = "True";
   else Ls_0 = "False";
   if (Download_Time_Offset == TRUE) Ls_8 = "True";
   else Ls_8 = "False";
   if (Take_Profit == 0) dbl2str_16 = "Off";
   else dbl2str_16 = DoubleToStr(Take_Profit, 0);
   if (Stop_Loss == 0) dbl2str_24 = "Off";
   else dbl2str_24 = DoubleToStr(Stop_Loss, 0);
   if (Funky_Take == 0) dbl2str_32 = "Off";
   else dbl2str_32 = DoubleToStr(Funky_Take, 0);
   if (Funky_Stop == 0) dbl2str_40 = "Off";
   else dbl2str_40 = DoubleToStr(Funky_Stop, 0);
   if (Double_Down == 0) dbl2str_48 = "Off";
   else dbl2str_48 = DoubleToStr(Double_Down, 0);
   if (Digits == 3 || Digits == 5) Li_56 = MarketInfo(Symbol(), MODE_SPREAD);
   else Li_56 = 10.0 * MarketInfo(Symbol(), MODE_SPREAD);
   if (Gi_188 == FALSE) {
      Comment("Unable to connect to MFM3 server.");
      return;
   }
   if (Gi_188 == 3) {
      Comment("Invalid Account!");
      return;
   }
   if (!IsConnected()) {
      Comment("Login to you trading account.");
      return;
   }
   if (Gi_188 == 2 && Download_Settings == TRUE) {
      Comment(Gs_160, 
      "\n", "There are no settings for this pair on the server! Turn off Download_Settings.");
      return;
   }
   if (f0_11() > 0 && Gi_192 == FALSE) Ls_60 = "The EA is managing open trades.";
   else {
      if (Gi_192 == TRUE) Ls_60 = "The EA is trading.";
      else Ls_60 = "The EA is not currently trading.";
   }
   Comment(Gs_160, 
      "\n", Ls_60, 
      "\n", 
      "\n", "Spread: ", Li_56, 
      "\n", "Lot Size: ", Gd_196, 
      "\n", "Download Time Offset: ", Ls_8, 
      "\n", "Time Offset: ", Time_Offset, 
      "\n", "Download Settings: ", Ls_0, 
      "\n", "Take Profit: ", dbl2str_16, 
      "\n", "Stop Loss: ", dbl2str_24, 
      "\n", "Funky Take: ", dbl2str_32, 
      "\n", "Funky Stop: ", dbl2str_40, 
      "\n", "Entry Size: ", Entry_Size, 
      "\n", "Frequency: ", Frequency, 
   "\n", "Double Down: ", dbl2str_48);
}

// 1FECAE449B84256D492CA4CFF7928A69
int f0_2() {
   if (Time_Offset == 17) return (Hour());
   if (Time_Offset == 18 && Hour() <= 0) return (Hour() + 23);
   if (Time_Offset == 18 && Hour() >= 1) return (Hour() - 1);
   if (Time_Offset == 19 && Hour() <= 1) return (Hour() + 22);
   if (Time_Offset == 19 && Hour() >= 2) return (Hour() - 2);
   if (Time_Offset == 20 && Hour() <= 2) return (Hour() + 21);
   if (Time_Offset == 20 && Hour() >= 3) return (Hour() - 3);
   if (Time_Offset == 21 && Hour() <= 3) return (Hour() + 20);
   if (Time_Offset == 21 && Hour() >= 4) return (Hour() - 4);
   if (Time_Offset == 22 && Hour() <= 4) return (Hour() + 19);
   if (Time_Offset == 22 && Hour() >= 5) return (Hour() - 5);
   if (Time_Offset == 23 && Hour() <= 5) return (Hour() + 18);
   if (Time_Offset == 23 && Hour() >= 6) return (Hour() - 6);
   if (Time_Offset == 0 && Hour() <= 6) return (Hour() + 17);
   if (Time_Offset == 0 && Hour() >= 7) return (Hour() - 7);
   if (Time_Offset == 1 && Hour() <= 7) return (Hour() + 16);
   if (Time_Offset == 1 && Hour() >= 8) return (Hour() - 8);
   if (Time_Offset == 2 && Hour() <= 8) return (Hour() + 15);
   if (Time_Offset == 2 && Hour() >= 9) return (Hour() - 9);
   if (Time_Offset == 3 && Hour() <= 9) return (Hour() + 14);
   if (Time_Offset == 3 && Hour() >= 10) return (Hour() - 10);
   if (Time_Offset == 4 && Hour() <= 10) return (Hour() + 13);
   if (Time_Offset == 4 && Hour() >= 11) return (Hour() - 11);
   if (Time_Offset == 5 && Hour() <= 11) return (Hour() + 12);
   if (Time_Offset == 5 && Hour() >= 12) return (Hour() - 12);
   if (Time_Offset == 6 && Hour() <= 12) return (Hour() + 11);
   if (Time_Offset == 6 && Hour() >= 13) return (Hour() - 13);
   if (Time_Offset == 7 && Hour() <= 13) return (Hour() + 10);
   if (Time_Offset == 7 && Hour() >= 14) return (Hour() - 14);
   if (Time_Offset == 8 && Hour() <= 14) return (Hour() + 9);
   if (Time_Offset == 8 && Hour() >= 15) return (Hour() - 15);
   if (Time_Offset == 9 && Hour() <= 15) return (Hour() + 8);
   if (Time_Offset == 9 && Hour() >= 16) return (Hour() - 16);
   if (Time_Offset == 10 && Hour() <= 16) return (Hour() + 7);
   if (Time_Offset == 10 && Hour() >= 17) return (Hour() - 17);
   if (Time_Offset == 11 && Hour() <= 17) return (Hour() + 6);
   if (Time_Offset == 11 && Hour() >= 18) return (Hour() - 18);
   if (Time_Offset == 12 && Hour() <= 18) return (Hour() + 5);
   if (Time_Offset == 12 && Hour() >= 19) return (Hour() - 19);
   if (Time_Offset == 13 && Hour() <= 19) return (Hour() + 4);
   if (Time_Offset == 13 && Hour() >= 20) return (Hour() - 20);
   if (Time_Offset == 14 && Hour() <= 20) return (Hour() + 3);
   if (Time_Offset == 14 && Hour() >= 21) return (Hour() - 21);
   if (Time_Offset == 15 && Hour() <= 21) return (Hour() + 2);
   if (Time_Offset == 15 && Hour() >= 22) return (Hour() - 22);
   if (Time_Offset == 16 && Hour() <= 22) return (Hour() + 1);
   if (Time_Offset == 16 && Hour() >= 23) return (Hour() - 23);
   return (0);
}

Recommend