int g_slippage_76 = 3; double gd_80 = 10.0; double gd_88 = 1.0; extern bool PositionSizing = TRUE; extern double Account_type = 1.0; extern double GMToffset = 0.0; double gd_116 = 0.3; double gd_124 = 0.0; double gd_132 = 0.6; double gd_140 = 0.0; double gd_148 = 0.1; int gi_156 = 800; int gi_160 = 190; double gd_164 = 1.0; double gd_172 = 1.0; double gd_180 = 1.0; double gd_188 = 1.0; double gd_196 = 1.0; int g_bars_204; int init() { return (0); } int deinit() { return (0); } int start() { int li_unused_0 = 3; int l_pos_4 = -1; int l_pos_8 = -1; int l_pos_12 = -1; int l_pos_16 = -1; int l_pos_20 = -1; int l_pos_24 = -1; int l_pos_28 = -1; int l_pos_32 = -1; int l_pos_36 = -1; int l_pos_40 = -1; int l_pos_44 = -1; int l_pos_48 = -1; int l_pos_52 = -1; int l_pos_56 = -1; int l_pos_60 = -1; int li_unused_64 = -1; int li_unused_68 = -1; int li_unused_72 = -1; for (int l_pos_76 = 0; l_pos_76 < OrdersTotal(); l_pos_76++) { OrderSelect(l_pos_76, SELECT_BY_POS); if (OrderMagicNumber() == 10) l_pos_4 = l_pos_76; if (OrderMagicNumber() == 20) l_pos_8 = l_pos_76; if (OrderMagicNumber() == 30) l_pos_12 = l_pos_76; if (OrderMagicNumber() == 40) l_pos_16 = l_pos_76; if (OrderMagicNumber() == 50) l_pos_20 = l_pos_76; if (OrderMagicNumber() == 60) l_pos_24 = l_pos_76; if (OrderMagicNumber() == 70) l_pos_28 = l_pos_76; if (OrderMagicNumber() == 80) l_pos_32 = l_pos_76; if (OrderMagicNumber() == 90) l_pos_36 = l_pos_76; if (OrderMagicNumber() == 100) l_pos_40 = l_pos_76; if (OrderMagicNumber() == 110) l_pos_44 = l_pos_76; if (OrderMagicNumber() == 120) l_pos_48 = l_pos_76; if (OrderMagicNumber() == 130) l_pos_52 = l_pos_76; if (OrderMagicNumber() == 140) l_pos_56 = l_pos_76; if (OrderMagicNumber() == 150) l_pos_60 = l_pos_76; if (OrderMagicNumber() == 160) li_unused_64 = l_pos_76; if (OrderMagicNumber() == 170) li_unused_68 = l_pos_76; if (OrderMagicNumber() == 180) li_unused_72 = l_pos_76; } if (g_bars_204 != Bars) { DayTime(l_pos_4, 10, 24, 4, 11); DayTime(l_pos_8, 20, 10, 13, 20); DayTime(l_pos_12, 7, 17, 15, 30); DayTime(l_pos_20, 31, 17, 11, 50); DayTime(l_pos_24, 24, 16, 0, 60); DayTimeSell(l_pos_16, 7, 24, 10, 41); DayTime2(l_pos_40, 17, 17, 10, 100); DayTime2(l_pos_44, 1, 16, 13, 110); DayTime2(l_pos_48, 13, 7, 16, 120); DayTimeSell2(l_pos_28, 18, 1, 24, 71); DayTimeSell2(l_pos_32, 15, 2, 16, 80); DayTimeSell2(l_pos_36, 19, 1, 16, 90); DayTime3(l_pos_52, 6, 4, 1, 131); DayTime3(l_pos_56, 6, 0, 6, 140); DayTime3(l_pos_60, 7, 22, 14, 150); } g_bars_204 = Bars; return (0); } int DayTime(int a_pos_0, int ai_4, int ai_8, int ai_12, int a_magic_16) { int l_ticket_20; double ld_24; double l_lots_32; double ld_40; int li_48; if (PositionSizing == TRUE) { if (gd_116 > 0.0) { ld_24 = gd_164 / 10.0 * gd_80; if (AccountCurrency() == "USD") ld_40 = AccountBalance() / (60000.0 / (10.0 * gd_116)) * ld_24; else if (AccountCurrency() == "JPY") ld_40 = AccountBalance() / (60000.0 * ((MarketInfo("USDJPY", MODE_BID) + MarketInfo("USDJPY", MODE_ASK)) / 2.0) / (10.0 * gd_116)) * ld_24; li_48 = 10.0 * ld_40; l_lots_32 = 10.0 * (li_48 / 10.0 / 10.0); if (l_lots_32 < Account_type / 10.0) l_lots_32 = Account_type / 10.0; } } else l_lots_32 = gd_116 * gd_88 * Account_type; int li_52 = SammerTime(); if (!IsTradeAllowed()) return (-1); if (a_pos_0 == -1) { if (TimeDay(TimeCurrent()) == ai_4) { if (TimeHour(TimeCurrent()) == ai_8 + li_52 + GMToffset - 2.0) { if ((TimeYear(TimeCurrent()) == 2006 && TimeMonth(TimeCurrent()) == 9 && TimeDay(TimeCurrent()) == 1) || (TimeYear(TimeCurrent()) == 2007 && TimeMonth(TimeCurrent()) == 7 && TimeDay(TimeCurrent()) == 31) || (TimeYear(TimeCurrent()) == 2006 && TimeMonth(TimeCurrent()) == 8 && TimeDay(TimeCurrent()) == 1) || (TimeYear(TimeCurrent()) == 2007 && TimeMonth(TimeCurrent()) == 7 && TimeDay(TimeCurrent()) == 24) || (TimeYear(TimeCurrent()) == 2008 && TimeMonth(TimeCurrent()) == 3 && TimeDay(TimeCurrent()) == 20) || TimeYear(TimeCurrent()) == 2008 && TimeMonth(TimeCurrent()) == 3 && TimeDay(TimeCurrent()) == 24) return (0); l_ticket_20 = OrderSend(Symbol(), OP_BUY, l_lots_32, Ask, g_slippage_76, Ask - gi_160 * Point, Ask + gi_156 * Point, "Buy", a_magic_16, 0, Blue); if (l_lots_32 > 0.0) { SendMail("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); Alert("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_16) { if (TimeHour(TimeCurrent()) == ai_12 + li_52 + GMToffset - 2.0) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_76, Green); if (l_lots_32 > 0.0) { SendMail("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); Alert("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); } } } } } } return (0); } int DayTime2(int a_pos_0, int ai_4, int ai_8, int ai_12, int a_magic_16) { int l_ticket_20; double ld_24; double l_lots_32; double ld_40; int li_48; if (PositionSizing == TRUE) { if (gd_132 > 0.0) { ld_24 = gd_172 / 10.0 * gd_80; if (AccountCurrency() == "USD") ld_40 = AccountBalance() / (60000.0 / (10.0 * gd_132)) * ld_24; else if (AccountCurrency() == "JPY") ld_40 = AccountBalance() / (60000.0 * ((MarketInfo("USDJPY", MODE_BID) + MarketInfo("USDJPY", MODE_ASK)) / 2.0) / (10.0 * gd_132)) * ld_24; li_48 = 10.0 * ld_40; l_lots_32 = 10.0 * (li_48 / 10.0 / 10.0); if (l_lots_32 < Account_type / 10.0) l_lots_32 = Account_type / 10.0; } } else l_lots_32 = gd_132 * gd_88 * Account_type; int li_52 = SammerTime(); if (!IsTradeAllowed()) return (-1); if (a_pos_0 == -1) { if (TimeDay(TimeCurrent()) == ai_4) { if (TimeHour(TimeCurrent()) == ai_8 + li_52 + GMToffset - 2.0) { if ((TimeYear(TimeCurrent()) == 2006 && TimeMonth(TimeCurrent()) == 6 && TimeDay(TimeCurrent()) == 29) || (TimeYear(TimeCurrent()) == 2006 && TimeMonth(TimeCurrent()) == 8 && TimeDay(TimeCurrent()) == 1) || (TimeYear(TimeCurrent()) == 2007 && TimeMonth(TimeCurrent()) == 7 && TimeDay(TimeCurrent()) == 17) || TimeYear(TimeCurrent()) == 2006 && TimeMonth(TimeCurrent()) == 9 && TimeDay(TimeCurrent()) == 1) return (0); l_ticket_20 = OrderSend(Symbol(), OP_BUY, l_lots_32, Ask, g_slippage_76, Ask - gi_160 * Point, Ask + gi_156 * Point, "Buy", a_magic_16, 0, Blue); if (l_lots_32 > 0.0) { SendMail("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); Alert("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_16) { if (TimeHour(TimeCurrent()) == ai_12 + li_52 + GMToffset - 2.0) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_76, Green); if (OrderLots() > 0.0) { SendMail("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); Alert("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); } } } } } } return (0); } int DayTime3(int a_pos_0, int ai_4, int ai_8, int ai_12, int a_magic_16) { int l_ticket_20; double ld_24; double l_lots_32; double ld_40; int li_48; if (PositionSizing == TRUE) { if (gd_140 > 0.0) { ld_24 = gd_180 / 10.0 * gd_80; if (AccountCurrency() == "USD") ld_40 = AccountBalance() / (60000.0 / (10.0 * gd_140)) * ld_24; else if (AccountCurrency() == "JPY") ld_40 = AccountBalance() / (60000.0 * ((MarketInfo("USDJPY", MODE_BID) + MarketInfo("USDJPY", MODE_ASK)) / 2.0) / (10.0 * gd_140)) * ld_24; li_48 = 10.0 * ld_40; l_lots_32 = 10.0 * (li_48 / 10.0 / 10.0); if (l_lots_32 < Account_type / 10.0) l_lots_32 = Account_type / 10.0; } } else l_lots_32 = gd_140 * gd_88 * Account_type; int li_52 = SammerTime(); if (!IsTradeAllowed()) return (-1); if (a_pos_0 == -1) { if (TimeDay(TimeCurrent()) == ai_4) { if (TimeHour(TimeCurrent()) == ai_8 + li_52 + GMToffset - 2.0) { l_ticket_20 = OrderSend(Symbol(), OP_BUY, l_lots_32, Ask, g_slippage_76, Ask - gi_160 * Point, Ask + gi_156 * Point, "Buy", a_magic_16, 0, Blue); if (l_lots_32 > 0.0) { SendMail("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); Alert("BUY!!Order " + Symbol() + " " + l_lots_32, "買いサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_16) { if (TimeHour(TimeCurrent()) == ai_12 + li_52 + GMToffset - 2.0) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_76, Green); if (OrderLots() > 0.0) { SendMail("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); Alert("BUY_OrderClose " + OrderSymbol() + " " + OrderLots(), "買いポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); } } } } } } return (0); } int DayTimeSell(int a_pos_0, int ai_4, int ai_8, int ai_12, int a_magic_16) { int l_ticket_20; double ld_24; double l_lots_32; double ld_40; int li_48; if (PositionSizing == TRUE) { if (gd_124 > 0.0) { ld_24 = gd_188 / 10.0 * gd_80; if (AccountCurrency() == "USD") ld_40 = AccountBalance() / (60000.0 / (10.0 * gd_124)) * ld_24; else if (AccountCurrency() == "JPY") ld_40 = AccountBalance() / (60000.0 * ((MarketInfo("USDJPY", MODE_BID) + MarketInfo("USDJPY", MODE_ASK)) / 2.0) / (10.0 * gd_124)) * ld_24; li_48 = 10.0 * ld_40; l_lots_32 = 10.0 * (li_48 / 10.0 / 10.0); if (l_lots_32 < Account_type / 10.0) l_lots_32 = Account_type / 10.0; } } else l_lots_32 = gd_124 * gd_88 * Account_type; int li_52 = SammerTime(); if (!IsTradeAllowed()) return (-1); if (a_pos_0 == -1) { if (TimeDay(TimeCurrent()) == ai_4) { if (TimeHour(TimeCurrent()) == ai_8 + li_52 + GMToffset - 2.0) { l_ticket_20 = OrderSend(Symbol(), OP_SELL, l_lots_32, Bid, g_slippage_76, Bid + gi_160 * Point, Bid - gi_156 * Point, "Sell", a_magic_16, 0, Red); if (l_lots_32 > 0.0) { SendMail("SELL!!Order " + Symbol() + " " + l_lots_32, "売りサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); Alert("SELL!!Order " + Symbol() + " " + l_lots_32, "売りサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_16) { if (TimeHour(TimeCurrent()) == ai_12 + li_52 + GMToffset - 2.0) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_76, Green); if (OrderLots() > 0.0) { SendMail("SELL_OrderClose " + OrderSymbol() + " " + OrderLots(), "売りポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); Alert("SELL_OrderClose " + OrderSymbol() + " " + OrderLots(), "売りポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); } } } } } } return (0); } int DayTimeSell2(int a_pos_0, int ai_4, int ai_8, int ai_12, int a_magic_16) { int l_ticket_20; double ld_24; double l_lots_32; double ld_40; int li_48; if (PositionSizing == TRUE) { if (gd_148 > 0.0) { ld_24 = gd_196 / 10.0 * gd_80; if (AccountCurrency() == "USD") ld_40 = AccountBalance() / (60000.0 / (10.0 * gd_148)) * ld_24; else if (AccountCurrency() == "JPY") ld_40 = AccountBalance() / (60000.0 * ((MarketInfo("USDJPY", MODE_BID) + MarketInfo("USDJPY", MODE_ASK)) / 2.0) / (10.0 * gd_148)) * ld_24; li_48 = 10.0 * ld_40; l_lots_32 = 10.0 * (li_48 / 10.0 / 10.0); if (l_lots_32 < Account_type / 10.0) l_lots_32 = Account_type / 10.0; } } else l_lots_32 = gd_148 * gd_88 * Account_type; int li_52 = SammerTime(); if (!IsTradeAllowed()) return (-1); Print("Trade context is free! Trying to open position..."); if (a_pos_0 == -1) { if (TimeDay(TimeCurrent()) == ai_4) { if (TimeHour(TimeCurrent()) == ai_8 + li_52 + GMToffset - 2.0) { if (TimeYear(TimeCurrent()) == 2005 && TimeMonth(TimeCurrent()) == 5 && TimeDay(TimeCurrent()) == 17 || TimeYear(TimeCurrent()) == 2005 && TimeMonth(TimeCurrent()) == 6 && TimeDay(TimeCurrent()) == 17) return (0); l_ticket_20 = OrderSend(Symbol(), OP_SELL, l_lots_32, Bid, g_slippage_76, Bid + gi_160 * Point, Bid - gi_156 * Point, "Sell", a_magic_16, 0, Red); if (l_lots_32 > 0.0) { SendMail("SELL!!Order " + Symbol() + " " + l_lots_32, "売りサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); Alert("SELL!!Order " + Symbol() + " " + l_lots_32, "売りサイン発生!!,通貨ペア:" + Symbol() + ",ロット数:" + l_lots_32 + "発注しました。"); } } } } else { OrderSelect(a_pos_0, SELECT_BY_POS); if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_16) { if (TimeHour(TimeCurrent()) == ai_12 + li_52 + GMToffset - 2.0) { if (OrderSymbol() == Symbol()) { if (OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_76, Green); if (OrderLots() > 0.0) { SendMail("SELL_OrderClose " + OrderSymbol() + " " + OrderLots(), "売りポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); Alert("SELL_OrderClose " + OrderSymbol() + " " + OrderLots(), "売りポジションをクローズしました。" + "通貨ペア:" + OrderSymbol() + ",オーダーチケット:" + OrderTicket() + ",ロット数:" + OrderLots()); } } } } } } return (0); } int SammerTime() { if (TimeMonth(TimeCurrent()) >= 4 && TimeMonth(TimeCurrent()) < 11) return (1); return (0); }