#property copyright "Viseu" #property link "http://agoagu.blog35.fc2.com/" extern int magic = 2008030801; extern int trade_open_time_h = 20; extern int trade_open_period_h = 1; bool gi_88 = FALSE; bool gi_92 = FALSE; bool gi_96 = FALSE; extern bool fixed_lot_enable = FALSE; extern double fixed_lot_size = 0.1; extern double leverage = 100.0; extern double lot_size_percent = 1.0; extern double lot_size_min = 0.1; extern double lot_size_max = 300.0; extern double tp = 6.0; extern double sl = 60.0; extern double slippage = 3.0; double gda_168[5][4]; int g_period_172 = 8; int g_period_176 = 17; int g_period_180 = 20; int g_period_184 = 29; int g_period_188 = 37; int gi_192 = 1; bool gi_196 = FALSE; int g_period_200 = 28; double gd_204 = 55.0; double gd_212 = 45.0; int gi_220 = 90; extern string accountholder = "Futoshi Takekiyo"; string gs_232 = "F"; string gs_240 = "u"; string gs_248 = "t"; string gs_256 = "o"; string gs_264 = "s"; string gs_272 = "h"; string gs_280 = "i"; string gs_288 = " "; string gs_296 = "T"; string gs_304 = "a"; string gs_312 = "k"; string gs_320 = "e"; string gs_328 = "k"; string gs_336 = "i"; string gs_344 = "y"; string gs_352 = "o"; string gs_360 = ""; string gs_368 = ""; string gs_376 = ""; string gs_384 = ""; string gs_392 = ""; string gs_400 = ""; string gs_408 = ""; string gs_416 = ""; string gs_424 = ""; string gs_432 = ""; string gs_440 = ""; string gs_448 = ""; string gs_456 = ""; string gs_464 = ""; string gs_472 = ""; string gs_480 = ""; string gs_488 = ""; string gs_496 = ""; string gs_504 = ""; string gs_512 = ""; string gs_520 = ""; string gs_528 = ""; string gs_536 = ""; string gs_544 = ""; string gs_552 = ""; string gs_560 = ""; string gs_568 = ""; string gs_576 = ""; string gs_584 = ""; string gs_592 = ""; string gs_600 = ""; string gs_608 = ""; string gs_616 = ""; string gs_624 = ""; extern string mt4_build_ver = "2.17"; extern int entry_level = 10; bool gi_644 = FALSE; int gi_648 = 30; int gi_652 = 30; int gi_656 = 30; extern bool is_broad_limit = FALSE; int gi_664 = 10; double gd_668 = 4.0; int g_count_676; int g_count_680; int gi_684; double gd_688; int gi_696 = 1; bool gba_700[2]; int gia_704[3]; bool gi_708 = FALSE; int g_datetime_712; bool gi_716; double gd_720; double gd_728 = 10.0; double gda_736[10][3]; double gda_740[10][3]; double g_ord_lots_744; double g_ord_lots_752; int gi_unused_760; int gi_unused_764; double g_ord_open_price_768; double g_ord_open_price_776; double gda_784[5][6]; string gsa_788[5]; int g_count_792; int init() { if (Period() != PERIOD_M30) { Alert("Please attach DP-002 Silverman to the chart of EURUSD M30."); return (-1); } string ls_0 = gs_232 + gs_240 + gs_248 + gs_256 + gs_264 + gs_272 + gs_280 + gs_288 + gs_296 + gs_304; string ls_8 = gs_312 + gs_320 + gs_328 + gs_336 + gs_344 + gs_352 + gs_360 + gs_368 + gs_376 + gs_384; string ls_16 = gs_392 + gs_400 + gs_408 + gs_416 + gs_424 + gs_432 + gs_440 + gs_448 + gs_456 + gs_464; string ls_24 = gs_472 + gs_480 + gs_488 + gs_496 + gs_504 + gs_512 + gs_520 + gs_528 + gs_536 + gs_544; string ls_32 = gs_552 + gs_560 + gs_568 + gs_576 + gs_584 + gs_592 + gs_600 + gs_608 + gs_616 + gs_624; string ls_40 = ls_0 + ls_8 + ls_16 + ls_24 + ls_32; if (AccountName() == ls_40) { if (accountholder == ls_40) if (gs_240 == "u" && gs_256 == "o" && gs_280 == "i" && gs_304 == "a" && gs_320 == "e") gi_708 = TRUE; } string ls_48 = AccountCurrency(); if (ls_48 == "USD") gd_688 = 100000; else { if (ls_48 == "JPY") gd_688 = 10000000; else { if (ls_48 == "EUR") gd_688 = 100000; else { if (ls_48 == "CHF") gd_688 = 100000; else { Alert("Only valid when account currency is USD, JPY, EUR or CHF."); Alert("Please email to office merteo."); Alert("We build EA for your account currency."); return (-1); } } } } if (lot_size_percent < 1.0) lot_size_percent = 1; if (lot_size_percent > 20.0) lot_size_percent = 20; if (lot_size_max < 0.01) lot_size_max = 0.01; if (lot_size_min < 0.01) lot_size_min = 0.01; if (lot_size_min > lot_size_max) lot_size_min = lot_size_max; if (leverage < 1.0) leverage = 1; if (trade_open_period_h < 1) trade_open_period_h = 1; if (trade_open_period_h > 3) trade_open_period_h = 3; if (trade_open_period_h == 3) { gi_88 = TRUE; gi_92 = TRUE; gi_96 = TRUE; } else { if (trade_open_period_h == 2) { gi_88 = TRUE; gi_92 = TRUE; } else gi_88 = TRUE; } gia_704[0] = trade_open_time_h; if (gia_704[0] < 0) { Print("Invalid parameter : trade_open_time_h = ", trade_open_time_h); gia_704[0] = 20; } if (gia_704[0] > 23) gia_704[0] = gia_704[0] - 24; gia_704[1] = gia_704[0] + 1; if (gia_704[1] > 23) gia_704[1] = gia_704[1] - 24; gia_704[2] = gia_704[1] + 1; if (gia_704[2] > 23) gia_704[2] = gia_704[2] - 24; g_datetime_712 = 0; gd_720 = 0.0; gi_716 = TRUE; if (lot_size_min < 0.1) gd_728 = 100; else gd_728 = 10; if (entry_level < 0) entry_level = 0; if (entry_level > 20) entry_level = 20; int li_56 = entry_level - 10; gd_204 = 55 - li_56 / 10.0; gd_212 = li_56 / 10.0 + 45.0; gd_668 = (gd_668 + 1.0) * Point; return (0); } void count_position() { g_count_676 = 0; g_count_680 = 0; for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == FALSE) break; if (OrderMagicNumber() == magic) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) g_count_676++; else if (OrderType() == OP_SELL) g_count_680++; } } } gi_684 = g_count_676 + g_count_680; } int is_trade_time() { bool li_ret_0 = FALSE; int l_datetime_4 = TimeCurrent(); int l_year_8 = TimeYear(l_datetime_4); int l_month_12 = TimeMonth(l_datetime_4); int l_day_of_week_16 = TimeDayOfWeek(l_datetime_4); int l_hour_20 = TimeHour(l_datetime_4); int l_minute_24 = TimeMinute(l_datetime_4); if (gi_708 == FALSE) return (0); int li_28 = 2030; if (l_year_8 > li_28) return (0); if (l_year_8 == li_28) if (l_month_12 > 3) return (0); if (l_day_of_week_16 >= 1 && l_day_of_week_16 <= 4) { if (l_hour_20 == gia_704[0] && gi_88 == TRUE) li_ret_0 = TRUE; else { if (l_hour_20 == gia_704[1] && gi_92 == TRUE) li_ret_0 = TRUE; else { if (l_hour_20 == gia_704[2] && gi_96 == TRUE) if (l_minute_24 <= 30) li_ret_0 = TRUE; } } } if (l_day_of_week_16 == 1 && l_hour_20 < 12) li_ret_0 = FALSE; return (li_ret_0); } void collect_position_info_broad() { int l_cmd_4; int l_ord_total_0 = OrdersTotal(); int l_index_8 = 0; g_count_792 = 0; for (int l_pos_12 = 0; l_pos_12 < l_ord_total_0 && l_index_8 < 5; l_pos_12++) { if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES) == FALSE) break; if (OrderMagicNumber() == magic) { l_cmd_4 = OrderType(); if (l_cmd_4 == OP_BUY || l_cmd_4 == OP_SELL) { gda_784[l_index_8][0] = OrderTicket(); gda_784[l_index_8][1] = l_cmd_4; gda_784[l_index_8][2] = OrderOpenPrice(); gda_784[l_index_8][3] = OrderTakeProfit(); gda_784[l_index_8][4] = OrderStopLoss(); gda_784[l_index_8][5] = OrderLots(); gsa_788[l_index_8] = OrderSymbol(); l_index_8++; g_count_792++; } } } } void collect_position_info() { double l_ord_lots_12; int l_ticket_20; int l_index_4 = 0; int l_index_8 = 0; count_position(); if (gi_684 >= 1) { ArrayInitialize(gda_736, 0.0); ArrayInitialize(gda_740, 0.0); g_ord_lots_744 = -1; g_ord_lots_752 = -1; for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == FALSE) break; if (OrderMagicNumber() == magic) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { l_ticket_20 = OrderTicket(); l_ord_lots_12 = OrderLots(); gda_736[l_index_4][0] = l_ticket_20; gda_736[l_index_4][1] = l_ord_lots_12; if (g_ord_lots_744 < l_ord_lots_12) { g_ord_lots_744 = l_ord_lots_12; gi_unused_760 = l_ticket_20; g_ord_open_price_768 = OrderOpenPrice(); } l_index_4++; } else { if (OrderType() == OP_SELL) { l_ticket_20 = OrderTicket(); l_ord_lots_12 = OrderLots(); gda_740[l_index_8][0] = l_ticket_20; gda_740[l_index_8][1] = l_ord_lots_12; if (g_ord_lots_752 < l_ord_lots_12) { g_ord_lots_752 = l_ord_lots_12; gi_unused_764 = l_ticket_20; g_ord_open_price_776 = OrderOpenPrice(); } l_index_8++; } } } } } } } double calc_position_size() { if (fixed_lot_enable == TRUE) return (fixed_lot_size); double ld_ret_0 = AccountFreeMargin() * leverage / gd_688 * lot_size_percent / 100.0; if (ld_ret_0 > lot_size_max) ld_ret_0 = lot_size_max; if (ld_ret_0 < lot_size_min) ld_ret_0 = lot_size_min; int li_8 = ld_ret_0 * gd_728; double ld_12 = li_8; ld_ret_0 = ld_12 / gd_728; return (ld_ret_0); } int judge_limit() { int l_ticket_8; int li_12; double ld_16; double ld_24; bool li_ret_0 = FALSE; for (int l_index_4 = 0; l_index_4 < g_count_792; l_index_4++) { ld_16 = (tp - 1.0) * Point; l_ticket_8 = gda_784[l_index_4][0]; li_12 = gda_784[l_index_4][1]; if (li_12 == 0) { ld_24 = Bid - gda_784[l_index_4][2]; if (ld_24 >= ld_16) { OrderClose(l_ticket_8, gda_784[l_index_4][5], Bid, slippage, White); li_ret_0 = TRUE; } } else { if (li_12 == 1) { ld_24 = gda_784[l_index_4][2] - Ask; if (ld_24 >= ld_16) { OrderClose(l_ticket_8, gda_784[l_index_4][5], Ask, slippage, White); li_ret_0 = TRUE; } } } } return (li_ret_0); } int start() { int l_ticket_28; int l_error_32; int li_44; int li_48; int li_52; double ld_56; int li_68; int li_72; double l_price_4 = 0.0; double l_price_12 = 0.0; double l_lots_20 = 1.0; if (IsTradeAllowed() != TRUE) return (0); if (gi_708 == FALSE) return (0); double ld_36 = AccountBalance(); if (ld_36 < gd_720) { g_datetime_712 = TimeCurrent(); gi_716 = TRUE; } if (gi_716 == TRUE) { li_44 = TimeCurrent() - g_datetime_712; li_48 = li_44 / 60; if (li_48 > gi_220) gi_716 = FALSE; } gd_720 = ld_36; if (gi_716 == TRUE) return (0); if (is_broad_limit == TRUE) { collect_position_info_broad(); if (g_count_792 > 0) { li_52 = judge_limit(); if (li_52 == 1) return (0); } } if (gi_644 == TRUE) { collect_position_info(); if (gi_684 == 1) { if (g_count_676 > 0) { ld_56 = Bid - g_ord_open_price_768; if (ld_56 < 0.0) { if (MathAbs(ld_56) / Point > gi_648) { l_price_4 = Ask + gi_652 * Point; l_price_12 = Ask - gi_656 * Point; OrderSend(Symbol(), OP_BUY, g_ord_lots_744, Ask, slippage, l_price_12, l_price_4, "DP-002 ", magic, 0, Blue); } } } if (g_count_680 > 0) { ld_56 = g_ord_open_price_776 - Ask; if (ld_56 < 0.0) { if (MathAbs(ld_56) / Point > gi_648) { l_price_4 = Bid - gi_652 * Point; l_price_12 = Bid + gi_656 * Point; OrderSend(Symbol(), OP_SELL, g_ord_lots_752, Bid, slippage, l_price_12, l_price_4, "DP-002 ", magic, 0, Red); } } } } } int li_0 = is_trade_time(); if (li_0 == 1) { count_position(); if (gi_684 < gi_696) { if (MathAbs(Ask - Bid) < gd_668) { if (get_signal() == 1) { l_lots_20 = calc_position_size(); if (is_broad_limit == TRUE) li_68 = gi_664; else li_68 = tp; li_72 = sl; if (gba_700[0] == 1) { if (li_68 != 0) l_price_4 = Ask + li_68 * Point; if (li_72 != 0) l_price_12 = Ask - li_72 * Point; l_ticket_28 = OrderSend(Symbol(), OP_BUY, l_lots_20, Ask, slippage, l_price_12, l_price_4, "DP-002 ", magic, 0, Yellow); if (l_ticket_28 < 0) { l_error_32 = GetLastError(); Print("DP-002 Error: OrderSend(BUY) = ", l_ticket_28, "Size = ", l_lots_20, " / Error = ", l_error_32); Sleep(5000); } } if (gba_700[1] == 1) { if (li_68 != 0) l_price_4 = Bid - li_68 * Point; if (li_72 != 0) l_price_12 = Bid + li_72 * Point; l_ticket_28 = OrderSend(Symbol(), OP_SELL, l_lots_20, Bid, slippage, l_price_12, l_price_4, "DP-002 ", magic, 0, Red); if (l_ticket_28 < 0) { l_error_32 = GetLastError(); Print("Error: OrderSend(SELL) = ", l_ticket_28, "Size = ", l_lots_20, " / Error = ", l_error_32); Sleep(5000); } } } } } } return (0); } int get_signal() { int l_index_12; double l_irsi_20; bool li_ret_0 = FALSE; int l_count_4 = 0; int l_count_8 = 0; ArrayInitialize(gba_700, 0); if (Bars >= 100) { l_index_12 = 0; for (int li_16 = gi_192; l_index_12 < 4; li_16++) { gda_168[0][l_index_12] = iMA(Symbol(), PERIOD_M30, g_period_172, 0, MODE_SMA, PRICE_CLOSE, li_16); gda_168[1][l_index_12] = iMA(Symbol(), PERIOD_M30, g_period_176, 0, MODE_SMA, PRICE_CLOSE, li_16); gda_168[2][l_index_12] = iMA(Symbol(), PERIOD_M30, g_period_180, 0, MODE_SMA, PRICE_CLOSE, li_16); gda_168[3][l_index_12] = iMA(Symbol(), PERIOD_M30, g_period_184, 0, MODE_SMA, PRICE_CLOSE, li_16); gda_168[4][l_index_12] = iMA(Symbol(), PERIOD_M30, g_period_188, 0, MODE_SMA, PRICE_CLOSE, li_16); l_index_12++; } l_irsi_20 = iRSI(Symbol(), PERIOD_M1, g_period_200, PRICE_CLOSE, 0); for (l_index_12 = 0; l_index_12 < 5; l_index_12++) if (gda_168[l_index_12][2] < gda_168[l_index_12][1] && gda_168[l_index_12][1] < gda_168[l_index_12][0]) l_count_4++; if (l_count_4 > 3 && l_irsi_20 <= gd_212) { if (gi_196 == FALSE) gba_700[0] = 1; else gba_700[1] = 1; li_ret_0 = TRUE; } for (l_index_12 = 0; l_index_12 < 5; l_index_12++) if (gda_168[l_index_12][2] > gda_168[l_index_12][1] && gda_168[l_index_12][1] > gda_168[l_index_12][0]) l_count_8++; if (l_count_8 > 3 && l_irsi_20 >= gd_204) { if (gi_196 == FALSE) gba_700[1] = 1; else gba_700[0] = 1; li_ret_0 = TRUE; } } return (li_ret_0); }