#property copyright "Copyright(c) 2008, MegaEgg" #property link "" string gs_76 = "Tomohiro Takahashi"; string gs_84 = "TOMOHIRO TAKAHASHI"; string gs_92 = "Takahashi Tomohiro"; string gs_100 = "Mr Tomohiro Takahashi"; string gs_108 = "Futoshi Takekiyo"; string gs_116 = "Takekiyo Futoshi"; string gs_eurgbp_124 = "EURGBP"; string gs_132 = "EURGBP."; string gs_140 = "EURGBP_"; string gs_eurgbpm_148 = "EURGBPm"; extern int Magic = 5020; extern double Lots = 0.1; extern int TP = 45; extern int SL = 35; extern int slippage = 3; bool gi_unused_180 = TRUE; extern bool Closeofmarketorder = FALSE; bool gi_188 = FALSE; int gi_192 = 0; extern double CloseParameter = 10.0; extern double OpenParameter = 9.0; extern string _000 = "Money_management"; extern bool Money_management = FALSE; extern int AccountType = 1; extern double risk = 0.0; double gd_236 = 1.0; int gi_244 = 0; int gi_248 = 1; int gi_unused_252 = 5; extern string _001 = "Timefilter"; extern bool TradeTimeFilter = TRUE; extern int OpenStartTime = 23; extern int TradePeriod = 4; extern bool MondayMoningFilter = TRUE; extern int MondayMoning = 1; extern bool FridayNightFilter = TRUE; extern int FridayNight = 15; extern bool LongTimeOpenPositionCloser = FALSE; extern int LongTimeOpenPositionHour = 3; extern int LongTimeOpenPositionMinute = 0; extern bool DayofweekFilter = FALSE; extern int Trade_Sun = 0; extern int Trade_Mon = 1; extern int Trade_Tue = 1; extern int Trade_Wed = 1; extern int Trade_Thu = 1; extern int Trade_Fri = 1; extern int Trade_Sat = 0; extern bool SpreadFilter = FALSE; extern int MaxSpread = 3; bool gi_344 = TRUE; int g_period_348 = 8; int gi_352 = 12; double gd_356 = 0.16; int g_period_364 = 18; double gd_368 = 40.0; int g_period_376 = 18; int gia_unused_380[10]; int gia_384[10]; int g_count_388 = 0; int g_pos_392 = 0; double g_price_396 = 0.0; double g_price_404 = 0.0; double g_ask_412 = 0.0; double g_bid_420 = 0.0; double g_lots_428 = 0.0; double g_lots_436 = 0.0; int g_cmd_444 = OP_BUY; int gia_448[10]; bool gi_452 = TRUE; double gda_456[10]; int gia_460[10]; double gd_unused_464 = 0.0; int gi_unused_472 = 0; int gi_unused_476 = 0; double gd_unused_480 = 0.0; double gd_unused_488 = 0.0; double gd_unused_496 = 0.0; string gs_504; string gs_dummy_512; int gi_520; int gi_524; int g_day_of_week_528; bool gi_532; int init() { return (0); } int deinit() { return (0); } int start() { int li_48; double ld_0 = CloseParameter / 10.0; HideTestIndicators(TRUE); if (AccountName() != gs_76 && AccountName() != gs_84 && AccountName() != gs_92 && AccountName() != gs_100 && AccountName() != gs_108 && AccountName() != gs_116) { Comment("Only for User:", gs_76, " Scramble !!! "); return (0); } if (Symbol() != gs_eurgbp_124 && Symbol() != gs_132 && Symbol() != gs_140 && Symbol() != gs_eurgbpm_148) { Comment("Only for Currency pair:", gs_eurgbp_124, " Trading is not Allowed !!"); return (0); } int li_8 = NormalizeDouble((Ask - Bid) / Point, 0); if (Money_management) { switch (AccountType) { case 0: g_lots_428 = NormalizeDouble(risk * AccountEquity() / 100000.0, 1); break; case 1: g_lots_428 = NormalizeDouble(risk * AccountEquity() / 100000.0, 2); break; case 2: g_lots_428 = NormalizeDouble(risk * AccountEquity() / 100000.0, 3); break; default: g_lots_428 = NormalizeDouble(MathCeil(risk * AccountEquity() / 10000.0) / 10.0, 1); } } else g_lots_428 = Lots; double l_ibands_16 = iBands(NULL, 0, g_period_376, 1, 0, PRICE_LOW, MODE_LOWER, 0); double l_ibands_24 = iBands(NULL, 0, g_period_376, 1, 0, PRICE_HIGH, MODE_UPPER, 0); double ld_32 = (l_ibands_24 - l_ibands_16) / 2.0; for (int l_index_40 = 0; l_index_40 <= 0; l_index_40++) { switch (l_index_40) { case 0: gs_504 = "01"; if (g_lots_428 <= 0.0) continue; gi_520 = TP; gi_524 = SL; break; case 1: gs_504 = "02"; break; default: gs_504 = ""; } g_count_388 = 0; for (g_pos_392 = 0; g_pos_392 < OrdersTotal(); g_pos_392++) { OrderSelect(g_pos_392, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic + l_index_40) g_count_388++; } if (gia_460[l_index_40] > g_count_388) CloseAllPosition(l_index_40); gia_460[l_index_40] = g_count_388; gi_452 = TRUE; if (g_count_388 >= gi_248) gi_452 = FALSE; if (gi_344 && MOMfilt() == 0) gi_452 = FALSE; if (gda_456[l_index_40] == 0.0) { for (g_pos_392 = 0; g_pos_392 < OrdersTotal(); g_pos_392++) { OrderSelect(g_pos_392, SELECT_BY_POS, MODE_TRADES); g_cmd_444 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic + l_index_40) { gda_456[l_index_40] = OrderOpenPrice(); if (g_cmd_444 == OP_BUY) gia_448[l_index_40] = 2; if (g_cmd_444 == OP_SELL) gia_448[l_index_40] = 1; } } } if (g_count_388 > 0) { if ((gia_448[l_index_40] == 1 && Ask <= gda_456[l_index_40] - gi_192 * Point) || (gia_448[l_index_40] == 2 && Bid >= gda_456[l_index_40] + gi_192 * Point)) { if (gia_448[l_index_40] == 2 && Bid > l_ibands_16 + ld_32 * ld_0) CloseAllPosition(l_index_40); if (!(gia_448[l_index_40] == 1 && Ask < l_ibands_24 - ld_32 * ld_0)) continue; CloseAllPosition(l_index_40); continue; } if (LongTimeOpenPositionCloser && Hour() == LongTimeOpenPositionHour && Minute() == LongTimeOpenPositionMinute) CloseAllPosition(l_index_40); } if (g_count_388 < 1) { if (TradeTimeFilter) { if (OpenStartTime + TradePeriod < 24) { li_48 = OpenStartTime + TradePeriod; if (Hour() < OpenStartTime || Hour() >= li_48) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading, Time Filter "); return (0); } } else { li_48 = OpenStartTime + TradePeriod - 24; if (Hour() < OpenStartTime && Hour() >= li_48) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading, Time Filter "); return (0); } } } if (SpreadFilter) { if (li_8 > MaxSpread) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading, SpreadFilter "); return (0); } } if (DayofweekFilter) { g_day_of_week_528 = DayOfWeek(); gi_532 = FALSE; switch (g_day_of_week_528) { case 0: if (Trade_Sun != 1) gi_532 = TRUE; break; case 1: if (Trade_Mon != 1) gi_532 = TRUE; break; case 2: if (Trade_Tue != 1) gi_532 = TRUE; break; case 3: if (Trade_Wed != 1) gi_532 = TRUE; break; case 4: if (Trade_Thu != 1) gi_532 = TRUE; break; case 5: if (Trade_Fri != 1) gi_532 = TRUE; break; case 6: if (Trade_Sat != 1) gi_532 = TRUE; break; default: gi_532 = TRUE; } if (gi_532 == TRUE) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading!!, DayofweekFilter "); return (0); } } if (MondayMoningFilter) { if (DayOfWeek() == 1 && Hour() < MondayMoning) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading!!, MondayMoningFilter "); return (0); } } if (FridayNightFilter) { if (DayOfWeek() == 5 && Hour() >= FridayNight) { Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n No trading!!, FridayNightFilter "); return (0); } } Comment("Spread: ", li_8, " Digits: ", Digits, " Lots:", g_lots_428, " Start at ", OpenStartTime, " for ", TradePeriod, " hours", "\n Trading is Allowed "); gia_448[l_index_40] = SIGN(l_index_40); } if (gia_448[l_index_40] == 1 && gi_452) { if (Bid - gda_456[l_index_40] >= gi_244 * Point || g_count_388 < 1) { g_bid_420 = Bid; gda_456[l_index_40] = 0; if (gi_520 == 0 || Closeofmarketorder == TRUE) g_price_404 = 0; else g_price_404 = g_bid_420 - gi_520 * Point; if (gi_524 == 0) g_price_396 = 0; else g_price_396 = NormalizeDouble(g_bid_420 + gi_524 * Point + (gi_248 - g_count_388) * gi_244 * Point, Digits); if (g_count_388 != 0) { g_lots_436 = g_lots_428; for (g_pos_392 = 1; g_pos_392 <= g_count_388; g_pos_392++) g_lots_436 = NormalizeDouble(g_lots_436 * gd_236, 2); } else g_lots_436 = g_lots_428; OrderSend(Symbol(), OP_SELL, g_lots_436, g_bid_420, slippage, g_price_396, g_price_404, "ME_Forex01", Magic + l_index_40, 0, Red); if (!(gi_188)) continue; Alert("ME_Forex01:", Symbol(), " by ", gs_504); continue; } } if (gia_448[l_index_40] == 2 && gi_452) { if (gda_456[l_index_40] - Ask >= gi_244 * Point || g_count_388 < 1) { g_ask_412 = Ask; gda_456[l_index_40] = 0; if (gi_520 == 0 || Closeofmarketorder == TRUE) g_price_404 = 0; else g_price_404 = g_ask_412 + gi_520 * Point; if (gi_524 == 0) g_price_396 = 0; else g_price_396 = NormalizeDouble(g_ask_412 - gi_524 * Point - (gi_248 - g_count_388) * gi_244 * Point, Digits); if (g_count_388 != 0) { g_lots_436 = g_lots_428; for (g_pos_392 = 1; g_pos_392 <= g_count_388; g_pos_392++) g_lots_436 = NormalizeDouble(g_lots_436 * gd_236, 2); } else g_lots_436 = g_lots_428; OrderSend(Symbol(), OP_BUY, g_lots_436, g_ask_412, slippage, g_price_396, g_price_404, "ME_Forex01", Magic + l_index_40, 0, Blue); if (gi_188) Alert("ME_Forex01:", Symbol(), " by ", gs_504); } } } return (0); } int SIGN(int ai_0) { double ld_4; double l_ibands_12; double l_ibands_20; double l_ima_28; double ld_36; HideTestIndicators(TRUE); gia_448[ai_0] = 3; if (ai_0 == 0) { ld_4 = OpenParameter / 5.0; l_ibands_12 = iBands(NULL, 0, g_period_364, 2, 0, PRICE_LOW, MODE_LOWER, 0); l_ibands_20 = iBands(NULL, 0, g_period_364, 2, 0, PRICE_HIGH, MODE_UPPER, 0); l_ima_28 = iMA(NULL, 0, g_period_364, 0, MODE_SMA, PRICE_CLOSE, 0); ld_36 = (l_ibands_20 - l_ibands_12) / 4.0; if (l_ibands_20 - l_ibands_12 > gd_368 * l_ima_28 / 10000.0) return (0); if (Close[0] < l_ima_28 - ld_36 * ld_4) gia_448[ai_0] = 2; if (Close[0] > l_ima_28 + ld_36 * ld_4) gia_448[ai_0] = 1; } else { if (ai_0 == 1) { } } return (gia_448[ai_0]); } int MOMfilt() { HideTestIndicators(TRUE); double l_ima_0 = iMA(NULL, 0, g_period_348, 0, MODE_SMA, PRICE_CLOSE, gi_352); double l_ima_8 = iMA(NULL, 0, g_period_348, 0, MODE_SMA, PRICE_CLOSE, 0); double ld_16 = 100.0 * ((l_ima_8 - l_ima_0) / l_ima_0); if (MathAbs(ld_16) < gd_356) return (1); return (0); } int CloseAllPosition(int ai_0) { for (g_pos_392 = OrdersTotal(); g_pos_392 >= 0; g_pos_392--) { OrderSelect(g_pos_392, SELECT_BY_POS, MODE_TRADES); g_cmd_444 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic + ai_0) { if (g_cmd_444 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Blue); if (g_cmd_444 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage, Red); } } gia_384[ai_0] = -1; return (0); }