Celui ci il est bon ??
#property copyright
#property link
/*#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);
#import*/
//extern string User = "Your ForexHacked.com Username";
extern string Warning = "Magic Number Must be UNIQUE for each chart!";
extern int MagicNumber = 133714;
extern double Lots = 0.01;
extern double TakeProfit = 132.0;
extern int PipStarter = 170;
extern double Booster = 2.3;
double gd_124 = 0.0;
int gi_132 = 0;
extern int MaxBuyOrders = 12;
extern int MaxSellOrders = 12;
extern int StartHour = 0;
extern int StopHour = 24;
int gi_152 = 55;
extern int StartingTradeDay = 0;
extern int EndingTradeDay = 5;
extern int slippage = 3;
int gi_168 = 10000;
int gi_172 = 0;
int gi_176 = 0;
extern double StopLossPct = 100.0;
double gd_188;
double gd_196;
bool gi_204;
int g_period_208 = 7;
int gi_212 = 0;
int g_ma_method_216 = MODE_LWMA;
int g_applied_price_220 = PRICE_WEIGHTED;
double gd_224 = 0.25;
double gd_232 = 0.2;
extern bool SupportECN = TRUE;
extern string Warning2 = "MassHedge Still In BETA!!!";
extern bool MassHedge = FALSE;
extern double MassHedgeBooster = 1.01;
extern int TradesDeep = 5;
int gi_268;
bool gi_unused_272 = FALSE;
string gs_dummy_276;
int gi_284;
int gi_288;
int gi_292 = 0;
int gi_296 = 1;
int gi_unused_300 = 3;
int gi_304 = 250;
string gs_308;
bool gi_316;
bool gi_320;
bool gi_324;
bool gi_328;
int g_ticket_332;
int g_cmd_336;
string gs__hedged_340 = " hedged";
int g_file_348;
void Log(string as_0) {
if (g_file_348 >= 0) FileWrite(g_file_348, TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS) + ": " + as_0);
}
int GetLotDigits() {
double ld_4 = MarketInfo(Symbol(), MODE_MINLOT);
for (int l_count_0 = 0; ld_4 < 1.0; l_count_0++) ld_4 = 10.0 * ld_4;
return (l_count_0);
}
double CalcLots(double ad_0) {
double l_minlot_32;
double ld_8 = AccountEquity() - gi_168;
double ld_16 = gi_172;
double ld_24 = gi_176;
if (gi_172 == 0 || gi_176 == 0) l_minlot_32 = ad_0;
else {
ld_16 = gi_168 * ld_16 / 100.0;
Print("tmp=" + ld_8 + ",AccountEquity()=" + AccountEquity() + ",InitEquity=" + gi_168);
ld_24 /= 100.0;
if (ld_8 > 0.0) ld_8 = MathPow(ld_24 + 1.0, ld_8 / ld_16);
else {
if (ld_8 < 0.0) ld_8 = MathPow(1 - ld_24, MathAbs(ld_8 / ld_16));
else ld_8 = 1;
}
l_minlot_32 = NormalizeDouble(ad_0 * ld_8, GetLotDigits());
if (l_minlot_32 < MarketInfo(Symbol(), MODE_MINLOT)) l_minlot_32 = MarketInfo(Symbol(), MODE_MINLOT);
}
if (l_minlot_32 < 0.0) Print("ERROR tmp=" + ld_8 + ",a=" + ld_16 + ",b=" + ld_24 + ",AccountEquity()=" + AccountEquity());
return (l_minlot_32);
}
/*int hSession(bool ai_0) {
string ls_4;
if (gi_284 == 0) {
ls_4 = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)";
gi_284 = InternetOpenA(ls_4, gi_292, "0", "0", 0);
gi_288 = InternetOpenA(ls_4, gi_296, "0", "0", 0);
}
if (ai_0) return (gi_288);
return (gi_284);
}
int GrabWeb(string as_0, string &as_8) {
int lia_24[] = {1};
string ls_28 = "x";
int li_16 = InternetOpenUrlA(hSession(0), as_0, "0", 0, -2080374528, 0);
if (li_16 == 0) return (0);
int li_20 = InternetReadFile(li_16, ls_28, gi_304, lia_24);
if (li_20 == 0) return (0);
int li_36 = lia_24[0];
for (as_8 = StringSubstr(ls_28, 0, lia_24[0]); lia_24[0] != 0; as_8 = as_8 + StringSubstr(ls_28, 0, lia_24[0])) {
li_20 = InternetReadFile(li_16, ls_28, gi_304, lia_24);
if (lia_24[0] == 0) break;
li_36 += lia_24[0];
}
li_20 = InternetCloseHandle(li_16);
if (li_20 == 0) return (0);
return (1);
}*/
int deinit() {
FileClose(g_file_348);
return (0);
}
int init() {
if (Digits == 3) {
gd_124 = 10.0 * TakeProfit;
gi_132 = 10.0 * PipStarter;
} else {
if (Digits == 5) {
gd_124 = 10.0 * TakeProfit;
gi_132 = 10.0 * PipStarter;
} else {
gd_124 = TakeProfit;
gi_132 = PipStarter;
}
}
gi_268 = MathRound((-MathLog(MarketInfo(Symbol(), MODE_LOTSTEP))) / 2.302585093);
gi_316 = FALSE;
gi_320 = FALSE;
gi_324 = FALSE;
gi_328 = FALSE;
g_ticket_332 = -1;
gi_204 = FALSE;
g_file_348 = FileOpen(WindowExpertName() + "_" + Time[0] + "_" + Symbol() + "_" + MagicNumber + ".log", FILE_WRITE);
g_cmd_336 = -1;
gs_308="approved";
/*if (IsDemo() == TRUE) gs_308 = "approved";
else {
GrabWeb("
http://www.ForexHacked.com/query.php?accountnumber=" + AccountNumber() + "&login=" + User, gs_308);
Print("init is done"
;);
return (0);
}*/
return (0);
}
int IsTradeTime() {
if (StartHour < StopHour && TimeHour(TimeCurrent()) < StartHour || TimeHour(TimeCurrent()) >= StopHour) return (0);
if (StartHour > StopHour && (TimeHour(TimeCurrent()) < StopHour && TimeHour(TimeCurrent()) >= StopHour)) return (0);
if (StopHour == 0) StopHour = 24;
if (Hour() == StopHour - 1 && Minute() >= gi_152) return (0);
return (1);
}
bool OpenBuy(bool ai_0 = FALSE) {
int l_ticket_4;
double l_lots_36;
double l_price_8 = 0;
double l_price_16 = 0;
string ls_24 = "";
bool li_ret_32 = TRUE;
if (ai_0 && !gi_324) return (FALSE);
if (!GlobalVariableCheck("PERMISSION"
;)) {
GlobalVariableSet("PERMISSION", TimeCurrent());
if (!SupportECN) {
if (ai_0) {
if (OrderSelect(g_ticket_332, SELECT_BY_TICKET)) l_price_16 = OrderTakeProfit() - MarketInfo(Symbol(), MODE_SPREAD) * Point;
} else l_price_8 = Ask + gd_124 * Point;
}
if (ai_0) ls_24 = gs__hedged_340;
if (IsTradeTime() == 1 && DayOfWeek() >= StartingTradeDay && DayOfWeek() <= EndingTradeDay) {
if (ai_0) l_lots_36 = CalcLots(gd_196);
else l_lots_36 = CalcLots(gd_188);
l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_36, Ask, slippage, l_price_16, l_price_8, "ForexHackedBuy™" + ls_24, MagicNumber, 0, Green);
if (l_ticket_4 != -1) {
if (!ai_0) {
g_ticket_332 = l_ticket_4;
Log("BUY hedgedTicket=" + g_ticket_332);
} else {
Log("BUY Hacked_ticket=" + l_ticket_4);
g_cmd_336 = 0;
}
} else {
Log("failed sell"
;);
li_ret_32 = FALSE;
}
}
GlobalVariableDel("PERMISSION"
;);
return (li_ret_32);
}
return (FALSE);
}
bool OpenSell(bool ai_0 = FALSE) {
int l_ticket_4;
double l_lots_36;
double l_price_8 = 0;
double l_price_16 = 0;
string ls_24 = "";
bool li_ret_32 = TRUE;
if (ai_0 && !gi_328) return (FALSE);
if (!GlobalVariableCheck("PERMISSION"
;)) {
GlobalVariableSet("PERMISSION", TimeCurrent());
if (!SupportECN) {
if (ai_0) {
if (OrderSelect(g_ticket_332, SELECT_BY_TICKET)) l_price_16 = OrderTakeProfit() + MarketInfo(Symbol(), MODE_SPREAD) * Point;
} else l_price_8 = Bid - gd_124 * Point;
}
if (ai_0) ls_24 = gs__hedged_340;
if (IsTradeTime() == 1 && DayOfWeek() >= StartingTradeDay && DayOfWeek() <= EndingTradeDay) {
if (ai_0) l_lots_36 = CalcLots(gd_196);
else l_lots_36 = CalcLots(gd_188);
l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_36, Bid, slippage, l_price_16, l_price_8, "ForexHackedSell™" + ls_24, MagicNumber, 0, Pink);
if (l_ticket_4 != -1) {
if (!ai_0) {
g_ticket_332 = l_ticket_4;
Log("SELL hedgedTicket=" + g_ticket_332);
} else {
Log("SELL Hacked_ticket=" + l_ticket_4);
g_cmd_336 = 1;
}
} else {
Log("failed sell"
;);
li_ret_32 = FALSE;
}
}
GlobalVariableDel("PERMISSION"
;);
return (li_ret_32);
}
return (FALSE);
}
void ManageBuy() {
int l_datetime_0 = 0;
double l_ord_open_price_4 = 0;
double l_ord_lots_12 = 0;
double l_ord_takeprofit_20 = 0;
int l_cmd_28 = -1;
int l_ticket_32 = 0;
int l_pos_36 = 0;
for (l_pos_36 = 0; l_pos_36 < OrdersTotal(); l_pos_36++) {
if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
if (OrderOpenTime() > l_datetime_0 && IsTradeTime() == 1) {
l_datetime_0 = OrderOpenTime();
l_ord_open_price_4 = OrderOpenPrice();
l_cmd_28 = OrderType();
l_ticket_32 = OrderTicket();
l_ord_takeprofit_20 = OrderTakeProfit();
}
if (OrderLots() > l_ord_lots_12) l_ord_lots_12 = OrderLots();
}
}
}
double l_isar_40 = iSAR(NULL, 0, gd_224, gd_232, 0);
double l_ima_48 = iMA(NULL, 0, g_period_208, gi_212, g_ma_method_216, g_applied_price_220, 0);
int li_56 = MathRound(MathLog(l_ord_lots_12 / Lots) / MathLog(Booster)) + 1.0;
int li_60 = MathRound(MathLog(l_ord_lots_12 / Lots) / MathLog(MassHedgeBooster)) + 1.0;
if (li_56 < 0) li_56 = 0;
if (li_60 < 0) li_60 = 0;
gd_188 = NormalizeDouble(Lots * MathPow(Booster, li_56), gi_268);
gd_196 = NormalizeDouble(Lots * MathPow(MassHedgeBooster, li_60), gi_268);
if (li_56 == 0 && l_isar_40 < l_ima_48) {
if (DayOfWeek() < EndingTradeDay || (DayOfWeek() >= StartingTradeDay && DayOfWeek() <= EndingTradeDay)) {
if (OpenBuy())
if (MassHedge) gi_316 = TRUE;
}
}
if (l_ord_open_price_4 - Ask > gi_132 * Point && li_56 < MaxBuyOrders) {
if (!(OpenBuy())) return;
if (!(MassHedge)) return;
gi_316 = TRUE;
return;
}
for (l_pos_36 = 0; l_pos_36 < OrdersTotal(); l_pos_36++) {
OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() != MagicNumber || OrderType() != OP_BUY || OrderTakeProfit() == l_ord_takeprofit_20 || l_ord_takeprofit_20 == 0.0) continue;
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_ord_takeprofit_20, 0, Pink);
}
}
void ManageSell() {
int l_datetime_0 = 0;
double l_ord_open_price_4 = 0;
double l_ord_lots_12 = 0;
double l_ord_takeprofit_20 = 0;
int l_cmd_28 = -1;
int l_ticket_32 = 0;
int l_pos_36 = 0;
for (l_pos_36 = 0; l_pos_36 < OrdersTotal(); l_pos_36++) {
if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
if (OrderOpenTime() > l_datetime_0 && IsTradeTime() == 1) {
l_datetime_0 = OrderOpenTime();
l_ord_open_price_4 = OrderOpenPrice();
l_cmd_28 = OrderType();
l_ticket_32 = OrderTicket();
l_ord_takeprofit_20 = OrderTakeProfit();
}
if (OrderLots() > l_ord_lots_12) l_ord_lots_12 = OrderLots();
}
}
}
double l_isar_40 = iSAR(NULL, 0, gd_224, gd_232, 0);
double l_ima_48 = iMA(NULL, 0, g_period_208, gi_212, g_ma_method_216, g_applied_price_220, 0);
int li_56 = MathRound(MathLog(l_ord_lots_12 / Lots) / MathLog(Booster)) + 1.0;
int li_60 = MathRound(MathLog(l_ord_lots_12 / Lots) / MathLog(MassHedgeBooster)) + 1.0;
if (li_56 < 0) li_56 = 0;
if (li_60 < 0) li_60 = 0;
gd_188 = NormalizeDouble(Lots * MathPow(Booster, li_56), gi_268);
gd_196 = NormalizeDouble(Lots * MathPow(MassHedgeBooster, li_56), gi_268);
if (li_56 == 0 && l_isar_40 > l_ima_48) {
if (DayOfWeek() < EndingTradeDay || (DayOfWeek() >= StartingTradeDay && DayOfWeek() <= EndingTradeDay)) {
if (OpenSell())
if (MassHedge) gi_320 = TRUE;
}
}
if (Bid - l_ord_open_price_4 > gi_132 * Point && l_ord_open_price_4 > 0.0 && li_56 < MaxSellOrders) {
if (!(OpenSell())) return;
if (!(MassHedge)) return;
gi_320 = TRUE;
return;
}
for (l_pos_36 = 0; l_pos_36 < OrdersTotal(); l_pos_36++) {
if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
if (OrderTakeProfit() == l_ord_takeprofit_20 || l_ord_takeprofit_20 == 0.0) continue;
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_ord_takeprofit_20, 0, Pink);
}
}
}
}
int start() {
double l_ord_takeprofit_16;
double l_price_24;
double l_price_32;
if (gs_308 != "approved"
;) {
Comment("Access denied!",
"\nMake you inputed your correct ForexHacked.com username into the EA paramaters",
"\nMake sure you login to
http://www.ForexHacked.com/membership/login.php and input your forex account number in your profile settings"
;);
return (0);
}
int l_count_4 = 0;
int l_count_8 = 0;
for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) {
if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) l_count_4++;
else
if (OrderType() == OP_SELL) l_count_8++;
}
}
}
if (l_count_4 >= TradesDeep) {
if (!gi_324) Log("Allow long hedge! trades=" + l_count_4 + ",TradesDeep=" + TradesDeep);
gi_324 = TRUE;
}
if (l_count_8 >= TradesDeep) {
if (!gi_328) Log("Dont Allow short hedge! trades=" + l_count_8 + ",TradesDeep=" + TradesDeep);
gi_328 = TRUE;
}
if ((100 - StopLossPct) * AccountBalance() / 100.0 >= AccountEquity()) {
Log("AccountBalance=" + AccountBalance() + ",AccountEquity=" + AccountEquity());
gi_204 = TRUE;
}
if (gi_204) {
for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) {
if (OrderSelect(l_pos_0, SELECT_BY_POS)) {
if (OrderMagicNumber() == MagicNumber) {
Log("close #" + OrderTicket());
if (!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), MarketInfo(Symbol(), MODE_SPREAD), White)) {
Log("error"
;);
return (0);
}
}
}
}
gi_204 = FALSE;
}
if (SupportECN) {
l_ord_takeprofit_16 = 0;
if (OrderSelect(g_ticket_332, SELECT_BY_TICKET)) l_ord_takeprofit_16 = OrderTakeProfit();
for (l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
if (OrderSelect(l_pos_0, SELECT_BY_POS)) {
if (OrderMagicNumber() == MagicNumber) {
if (OrderTakeProfit() == 0.0 && StringFind(OrderComment(), gs__hedged_340) == -1) {
if (OrderType() == OP_BUY) OrderModify(OrderTicket(), 0, OrderStopLoss(), OrderOpenPrice() + gd_124 * Point, 0, White);
else
if (OrderType() == OP_SELL) OrderModify(OrderTicket(), 0, OrderStopLoss(), OrderOpenPrice() - gd_124 * Point, 0, White);
} else {
if (StringFind(OrderComment(), gs__hedged_340) != -1 && g_cmd_336 == OrderType()) {
l_price_24 = l_ord_takeprofit_16 - MarketInfo(Symbol(), MODE_SPREAD) * Point;
l_price_32 = l_ord_takeprofit_16 + MarketInfo(Symbol(), MODE_SPREAD) * Point;
if (OrderStopLoss() == 0.0 || (OrderType() == OP_BUY && OrderStopLoss() != l_price_24) || (OrderType() == OP_SELL && OrderStopLoss() != l_price_32)) {
if (OrderType() == OP_BUY) OrderModify(OrderTicket(), 0, l_price_24, OrderTakeProfit(), 0, White);
else
if (OrderType() == OP_SELL) OrderModify(OrderTicket(), 0, l_price_32, OrderTakeProfit(), 0, White);
}
}
}
}
}
}
}
if (Check() != 0) {
ManageBuy();
ManageSell();
if (gi_320)
if (OpenBuy(1)) gi_320 = FALSE;
if (gi_316)
if (OpenSell(1)) gi_316 = FALSE;
ChartComment();
return (0);
}
return (0);
}
void ChartComment() {
string l_dbl2str_0 = DoubleToStr(balanceDeviation(2), 2);
Comment(" \nForexHacked V2.0™ ",
"\nAccount Leverage : " + "1 : " + AccountLeverage(),
"\nAccount Type : " + AccountServer(),
"\nServer Time : " + TimeToStr(TimeCurrent(), TIME_SECONDS),
"\nAccount Equity = ", AccountEquity(),
"\nFree Margin = ", AccountFreeMargin(),
"\nDrawdown : ", l_dbl2str_0, "%\n"
;);
}
int Check() {
return (1);
}
double balanceDeviation(int ai_0) {
double ld_ret_4;
if (ai_0 == 2) {
ld_ret_4 = (AccountEquity() / AccountBalance() - 1.0) / (-0.01);
if (ld_ret_4 > 0.0) return (ld_ret_4);
return (0);
}
if (ai_0 == 1) {
ld_ret_4 = 100.0 * (AccountEquity() / AccountBalance() - 1.0);
if (ld_ret_4 > 0.0) return (ld_ret_4);
return (0);
}
return (0.0);
}