Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi, I have this EA which I got from here: Index of /mt_yahoo/ex4 called HedgeMadnessBUY
here is the decompiled code :
/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: https://www.mql5.com/go?link=http://purebeam.biz/
E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2008, David E. Fulton"
#property link "www.defulton.com/forex"
string gs_76 = "HedgeMadness EA V1.0 Build 001 AS1";
extern string INFO = "HedgeMadness EA V1.0 Build 001 AS1";
extern string OWN = "Copyright © 2008, David E. Fulton";
extern string ContactMe = "david@defulton.com";
bool gi_108 = FALSE;
string gs_unused_112 = "--STOCH SETTING--";
bool gi_120 = FALSE;
int g_period_124 = 14;
int g_period_128 = 3;
int g_slowing_132 = 3;
int g_timeframe_136 = PERIOD_M1;
int g_shift_140 = 1;
int gi_144 = 99;
int gi_148 = 1;
string gs_unused_152 = "Choose 1=mode main, 2=mode signal";
int gi_160 = 1;
string gs_unused_164 = "Choose 1=mode SMA, 2=mode LWMA, 3=mode EMA";
int gi_172 = 2;
bool gi_176 = FALSE;
extern string TS = "--TRADE SETTING--";
string gs_unused_188 = "0=Buy & Sell, 1=Sell, 2=Buy";
int gi_196 = 2;
extern double Lots = 0.01;
extern int TakeProfit = 100;
bool gi_212 = FALSE;
double gd_216 = 50.0;
extern double Multiplier = 2.0;
extern int MaxTrades = 10;
extern int PipStep = 80;
int gi_240 = 0;
int gi_244 = 0;
string gs_unused_248 = "--MOney Management--";
string gs_unused_256 = "if one the lots size will increase based on account size";
int gi_264 = 0;
string gs_unused_268 = "risk to calculate the lots size (only if mm is enabled)";
int gi_276 = 1;
string gs_unused_280 = "0 if Normal Lots, 1 for mini lots, 2 for micro lots";
int gi_288 = 2;
string gs_unused_292 = "--Magic No--";
int g_magic_300;
string gs_unused_304 = "--CUTLOSS SETTING--";
bool gi_312 = FALSE;
string gs_unused_316 = "If profit made is bigger than SecureProfit we close the orders";
int gi_324 = 20;
string gs_unused_328 = "Number of orders to enable the account protection";
int gi_336 = 3;
string gs_unused_340 = "if one will check profit from all symbols, if cero only this symbol";
bool gi_348 = FALSE;
string gs_unused_352 = "if true, then the expert will protect the account equity to the percent specified";
bool gi_360 = FALSE;
string gs_unused_364 = "percent of the account to protect on a set of trades";
int gi_372 = 90;
string gs_unused_376 = "if true, then the expert will use money protection to the USD specified";
bool gi_384 = FALSE;
double gd_388 = 3000.0;
bool gi_396 = FALSE;
int gi_400 = 0;
int gi_404 = 1;
string gs_unused_408 = "--trading time setting--";
bool gi_416 = FALSE;
bool gi_420 = TRUE;
int gi_424 = 0;
int gi_428 = 3;
bool gi_432 = TRUE;
int gi_436 = 9;
int gi_440 = 11;
bool gi_444 = TRUE;
int gi_448 = 15;
int gi_452 = 17;
bool gi_456 = TRUE;
string gs_unused_460 = "--Others Setting--";
int gi_468 = 0;
string gs_unused_472 = "if one the desition to go long/short will be reversed";
bool gi_480 = FALSE;
string gs_unused_484 = "if true, instead open market orders it will open limit orders ";
bool gi_492 = FALSE;
int gi_496 = 0;
int g_color_500 = Black;
int gi_504 = 16;
bool gi_508 = TRUE;
int g_count_512 = 0;
int gi_unused_516 = 0;
int g_count_520 = 0;
int g_count_524 = 0;
int g_slippage_528 = 5;
double g_price_532 = 0.0;
double g_price_540 = 0.0;
double g_ask_548 = 0.0;
double g_bid_556 = 0.0;
double gd_564 = 0.0;
double g_lots_572 = 0.0;
int g_cmd_580 = OP_BUY;
int gi_584 = 0;
int gi_588 = 0;
double g_ord_open_price_592 = 0.0;
int gi_600 = 0;
double gd_604 = 0.0;
int gi_unused_612 = 0;
int gi_unused_616 = 0;
double gd_unused_620 = 0.0;
double gd_unused_628 = 0.0;
double gd_unused_636 = 0.0;
double g_tickvalue_644 = 0.0;
bool gi_unused_652 = FALSE;
double gd_unused_656 = 0.0;
double gd_unused_664 = 0.0;
double gd_unused_672 = 0.0;
int gia_unused_680[][2];
bool gi_unused_684 = FALSE;
string gs_unused_688 = "2030.01.12 23:00";
int gi_unused_696 = 0;
int g_datetime_700 = 0;
bool gi_704;
int init() {
if (gi_196 == 0) g_magic_300 = 222666;
if (gi_196 == 1) g_magic_300 = 222777;
if (gi_196 == 2) g_magic_300 = 222888;
return (0);
}
int deinit() {
DeleteAllObjects();
return (0);
}
int start() {
bool l_bool_4;
int li_16;
int l_pos_0 = 0;
string ls_8 = "";
if (GlobalVariableGet("GV_CloseAllAndHalt") > 0.0) {
gi_508 = FALSE;
return (0);
}
if (gi_416) {
gi_704 = TRUE;
if (gi_420) {
if (gi_424 > 18) {
if (Hour() >= gi_424) gi_704 = FALSE;
if (!gi_704) {
if (gi_428 < 24)
if (Hour() <= gi_428) gi_704 = FALSE;
if (gi_428 >= 0)
if (Hour() <= gi_428) gi_704 = FALSE;
}
} else
if (Hour() >= gi_424 && Hour() <= gi_428) gi_704 = FALSE;
}
if (gi_704) {
if (gi_432)
if (Hour() >= gi_436 && Hour() <= gi_440) gi_704 = FALSE;
}
if (gi_704) {
if (gi_444)
if (Hour() >= gi_448 && Hour() <= gi_452) gi_704 = FALSE;
}
if (gi_704) return (0);
}
if (gi_288 == 0) {
if (gi_264 != 0) gd_564 = MathCeil(AccountBalance() * gi_276 / 10000.0);
else gd_564 = Lots;
}
if (gi_288 == 1) {
if (gi_264 != 0) gd_564 = MathCeil(AccountBalance() * gi_276 / 10000.0) / 10.0;
else gd_564 = Lots;
}
if (gi_288 == 2) {
if (gi_264 != 0) gd_564 = MathCeil(AccountBalance() * gi_276 / 10000.0) / 100.0;
else gd_564 = Lots;
}
if (gd_564 < 0.01) gd_564 = 0.01;
if (gd_564 > 100.0) gd_564 = 100;
g_count_512 = 0;
g_count_520 = 0;
g_count_524 = 0;
for (l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_300) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
g_count_520++;
g_datetime_700 = OrderOpenTime();
}
if (OrderType() == OP_SELLLIMIT || OrderType() == OP_BUYLIMIT) g_count_524++;
g_count_512++;
}
}
}
if (g_count_512 < 1)
if (!gi_456 && DayOfWeek() == 5) return (0);
g_tickvalue_644 = MarketInfo(Symbol(), MODE_TICKVALUE);
if (g_tickvalue_644 == 0.0) g_tickvalue_644 = 5;
if (gi_384 && AccountBalance() - AccountEquity() >= gd_388) {
ls_8 = ls_8
+ "\nClosing all orders and stop trading because account money protection activated..";
Print("Closing all orders and stop trading because account money protection activated.. Balance: ", AccountBalance(), " Equity: ", AccountEquity());
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
return (0);
}
if (gi_396) {
if (!(Hour() >= gi_400 && Hour() <= gi_404)) {
ls_8 = ls_8
+ "\nNot the designated trading hours.";
Print("Not the designated trading hours. Profit: ", AccountProfit(), " Equity: ", AccountEquity());
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
return (0);
}
}
if (gi_212 && AccountProfit() >= gd_216) {
ls_8 = ls_8
+ "\nClosing all orders and stop trading because mymoney profit target reached..";
Print("Closing all orders and stop trading because mymoney profit target reached.. Profit: ", AccountProfit(), " Equity: ", AccountEquity());
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
return (0);
}
if (gi_360 && AccountEquity() <= AccountBalance() * gi_372 / 100.0) {
ls_8 = ls_8
+ "\nClosing all orders and stop trading because account money protection activated.";
Print("Closing all orders and stop trading because account money protection activated. Balance: ", AccountBalance(), " Equity: ", AccountEquity());
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
return (0);
}
if (!gi_456 && DayOfWeek() == 5) {
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
ls_8 = ls_8
+ "\nClosing all orders and stop trading because TradeOnFriday protection.";
Print("Closing all orders and stop trading because TradeOnFriday protection.");
}
if (gi_468 > 0 && TimeCurrent() - g_datetime_700 > gi_468) {
gi_600 = g_count_512 + 1;
gi_508 = FALSE;
ls_8 = ls_8
+ "\nClosing all orders because OrdersTimeAlive protection.";
Print("Closing all orders because OrdersTimeAlive protection.");
}
if (gi_600 > g_count_512) {
for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) {
g_cmd_580 = OrderType();
if ((OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_300) || gi_348) {
if (g_cmd_580 == OP_BUY || g_cmd_580 == OP_SELL) {
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_528, g_color_500);
return (0);
}
}
}
}
for (l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) {
g_cmd_580 = OrderType();
if ((OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_300) || gi_348) {
if (g_cmd_580 == OP_SELLLIMIT || g_cmd_580 == OP_BUYLIMIT || g_cmd_580 == OP_BUYSTOP || g_cmd_580 == OP_SELLSTOP) {
OrderDelete(OrderTicket());
return (0);
}
}
}