int gi_76 = 2010; int gi_80 = 2; int gi_84 = 28; int gia_88[100] = {586870}; bool gi_92 = FALSE; bool gi_96 = FALSE; int g_magic_100 = 2009002; extern double ManualLots = 0.01; extern double PipsStep = 50.0; extern string Type_PipStep = "false: Every PipsStep true: PipsStep*OpenOrders"; extern bool PipsStepPlus = TRUE; extern double TP_Offset = 1.0; extern string LM = "--------------------------"; extern bool LotManagement = TRUE; extern int LotControlStep = 5800; extern double LotStepPlus = 0.06; extern bool LSP_Turbo = TRUE; extern string Stop_and_Losscut = "--------------------------"; extern int StopTrades = 4; extern int LosscutTrades = 4; extern string Filter_DayTime = "--------------------------"; extern bool TimeFilter = TRUE; extern int StopTime = 16; extern int StartTime = 20; extern bool FridayFilter = TRUE; extern int FridayStopTime = 11; extern int FridayStartTime = 17; extern bool DayFilter = TRUE; extern int StopMonth = 2; extern int StopDay = 10; extern int StartMonth = 3; extern int StartDay = 10; extern bool SummerTimeTable = FALSE; extern double MA_Period = 20.0; extern int FastEMA = 12; extern int SlowEMA = 26; extern int SignalSMA = 9; extern int RPeriod = 14; extern bool UsePercent = TRUE; extern int KPeriod = 14; extern int DPeriod = 3; extern int Slowing = 3; string g_comment_280 = "USDJPY-M5-E14"; int g_count_288 = 0; int g_pos_292 = 0; int g_slippage_296 = 5; int g_cmd_300 = OP_BUY; int gi_304 = 0; int gi_308 = 0; int g_ticket_312 = 0; int gi_316 = 0; int gi_320 = 0; int gi_324 = 0; int gi_328 = 0; int g_count_332 = 0; int gi_336 = 0; int gi_340 = 0; double g_price_344 = 0.0; double g_price_352 = 0.0; double g_price_360 = 0.0; double g_price_368 = 0.0; double gd_376 = 0.0; double g_lots_384 = 0.0; double g_ord_open_price_392 = 0.0; double gd_400 = 0.0; double g_price_408 = 0.0; double g_ord_lots_416 = 0.0; double gd_424 = 0.0; double gd_432 = 0.0; double gd_440 = 0.0; double gd_448 = 0.0; double gd_456 = 0.0; double gd_464 = 0.0; bool gi_472 = TRUE; string gs_476 = ""; int init() { gi_92 = CheckAccountFunction(); gi_96 = LimitFunction(); if (gi_92) Print("Account setting was approved."); if (gi_96) Print("Date setting was approved."); return (0); } int deinit() { return (0); } int start() { int l_datetime_0; bool li_4; int li_8; int li_12; int li_16; if (!gi_92) { Comment("\nTrading is not allowed. Wrong account : " + AccountNumber()); return (0); } if (!gi_96) { Comment("\nDate is invalid."); return (0); } double ld_20 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); double ld_28 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); double ld_36 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSIZE), 0); double l_tickvalue_44 = MarketInfo(Symbol(), MODE_TICKVALUE); if (ManualLots < ld_20) { gd_432 = ld_20; PlaySound("alert.wav"); MessageBox("!! The lot setting value is wrong. Please set it again. !!"); return (0); } if (ManualLots >= ld_20) gd_432 = ManualLots; int li_52 = (AccountBalance() + LotControlStep) / LotControlStep; if (li_52 < 1) li_52 = 1; if (LotManagement) gd_376 = NormalizeDouble(gd_432 * li_52, 2); else gd_376 = gd_432; if (gd_376 < ld_20) gd_376 = ld_20; if (gd_376 > ld_28) gd_376 = ld_28; gi_340 = 0; if (SummerTimeTable) { l_datetime_0 = TimeCurrent(); if (TimeMonth(l_datetime_0) > 3 && TimeMonth(l_datetime_0) < 11) gi_340 = 1; if (TimeMonth(l_datetime_0) == 3) { if (TimeDay(l_datetime_0) >= 14) gi_340 = 1; else { if (DayOfWeek() == 0) gi_336 = TimeDay(l_datetime_0) + 6; if (DayOfWeek() == 1) gi_336 = TimeDay(l_datetime_0) + 5; if (DayOfWeek() == 2) gi_336 = TimeDay(l_datetime_0) + 4; if (DayOfWeek() == 3) gi_336 = TimeDay(l_datetime_0) + 3; if (DayOfWeek() == 4) gi_336 = TimeDay(l_datetime_0) + 2; if (DayOfWeek() == 5) gi_336 = TimeDay(l_datetime_0) + 1; if (DayOfWeek() == 6) gi_336 = TimeDay(l_datetime_0); if (gi_336 >= 14) gi_340 = 1; } } if (TimeMonth(l_datetime_0) == 11) { if (DayOfWeek() == 1) gi_336 = TimeDay(l_datetime_0) + 5; if (DayOfWeek() == 2) gi_336 = TimeDay(l_datetime_0) + 4; if (DayOfWeek() == 3) gi_336 = TimeDay(l_datetime_0) + 3; if (DayOfWeek() == 4) gi_336 = TimeDay(l_datetime_0) + 2; if (DayOfWeek() == 5) gi_336 = TimeDay(l_datetime_0) + 1; if (DayOfWeek() == 6) gi_336 = TimeDay(l_datetime_0); if (gi_336 <= 6) gi_340 = 1; } } g_count_288 = 0; gd_448 = 0; gi_324 = 0; for (g_pos_292 = 0; g_pos_292 < OrdersTotal(); g_pos_292++) { OrderSelect(g_pos_292, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_100) { g_count_288++; gd_448 += OrderLots(); if (g_count_288 > 1) gi_324 = gi_324 + g_count_288 - 1; } } if (gi_308 > g_count_288) { for (g_pos_292 = OrdersTotal(); g_pos_292 >= 0; g_pos_292--) { OrderSelect(g_pos_292, SELECT_BY_POS, MODE_TRADES); g_cmd_300 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_100) { if (g_cmd_300 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), 2), g_slippage_296, Blue); if (g_cmd_300 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), 2), g_slippage_296, Red); return (0); } } } gi_308 = g_count_288; if (g_count_288 >= StopTrades) gi_472 = FALSE; else gi_472 = TRUE; if (g_ord_open_price_392 == 0.0) { for (g_pos_292 = 0; g_pos_292 < OrdersTotal(); g_pos_292++) { OrderSelect(g_pos_292, SELECT_BY_POS, MODE_TRADES); g_cmd_300 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_100) { g_ord_open_price_392 = OrderOpenPrice(); if (g_cmd_300 == OP_BUY) gi_304 = 2; if (g_cmd_300 == OP_SELL) gi_304 = 1; } } } if (g_count_288 < 1) { if (DayFilter) { if (StopMonth <= StartMonth) { if (Month() >= StopMonth || Month() <= StartMonth && (Month() == StopMonth && Day() >= StopDay) || (Month() == StartMonth && Day() < StartDay) || (Month() > StopMonth && Month() < StartMonth)) { Comment("No trading, Working Time Filter"); return (0); } } if (StopMonth > StartMonth) { if (Month() >= StopMonth || Month() <= StartMonth && (Month() == StopMonth && Day() >= StopDay) || (Month() == StartMonth && Day() < StartDay) || Month() > StopMonth || Month() < StartMonth) { Comment("No trading, Working Time Filter"); return (0); } } } if (TimeFilter) { if (StopTime <= StartTime) { if (Hour() >= StopTime - gi_340 && Hour() < StartTime - gi_340) { Comment("No trading, Working Time Filter"); return (0); } } if (StopTime > StartTime) { if (Hour() >= StopTime - gi_340 || Hour() < StartTime - gi_340) { Comment("No trading, Working Time Filter"); return (0); } } } gi_304 = Ind(); } gd_400 = 0; g_ticket_312 = 0; gi_316 = FALSE; g_price_408 = 0; g_ord_lots_416 = 0; for (g_pos_292 = 0; g_pos_292 < OrdersTotal(); g_pos_292++) { OrderSelect(g_pos_292, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_100) { g_ticket_312 = OrderTicket(); if (OrderType() == OP_BUY) gi_316 = FALSE; if (OrderType() == OP_SELL) gi_316 = TRUE; g_price_408 = NormalizeDouble(OrderClosePrice(), 2); g_ord_lots_416 = OrderLots(); if (gi_316 == FALSE) { if (OrderClosePrice() < OrderOpenPrice()) gd_400 -= (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; if (OrderClosePrice() > OrderOpenPrice()) gd_400 += (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; } if (gi_316 == TRUE) { if (OrderClosePrice() > OrderOpenPrice()) gd_400 -= (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; if (OrderClosePrice() < OrderOpenPrice()) gd_400 += (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; } } } gd_400 *= l_tickvalue_44; if (g_count_288 >= 1) { if (gd_400 >= gd_376 * (ld_36 / 1000.0) * TP_Offset) { OrderClose(g_ticket_312, g_ord_lots_416, g_price_408, g_slippage_296, Yellow); gi_472 = FALSE; return (0); } } if (FridayFilter) { if (FridayStopTime <= FridayStartTime) { if (FridayStopTime == 0 && gi_340 != 0) { if (DayOfWeek() >= 5 && Hour() >= 23 || Hour() < FridayStartTime - gi_340) { Comment("No trading, Working Friday Filter"); return (0); } } else { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_340 && Hour() < FridayStartTime - gi_340) { Comment("No trading, Working Friday Filter"); return (0); } } } if (FridayStopTime > FridayStartTime) { if (FridayStartTime == 0 && gi_340 != 0) { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_340 && Hour() < 23) { Comment("No trading, Working Friday Filter"); return (0); } } else { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_340 || Hour() < FridayStartTime - gi_340) { Comment("No trading, Working Friday Filter"); return (0); } } } } if (!IsTesting()) { if (gi_304 == 3) gs_476 = "The trading signal is waited for"; else gs_476 = gd_400 - gd_376 * (ld_36 / 1000.0) * TP_Offset; Comment(" >>>>> ", AccountCompany(), "\n >>>>> TotalLots = ", gd_448, "\n >>>>> Open Order Delay Until Loss Cut = ", LosscutTrades - g_count_288, "\n >>>>> Monitor ", gs_476); } if (PipsStepPlus == TRUE) { if (g_count_288 >= 2) gi_320 = g_count_288; if (g_count_288 <= 1) gi_320 = TRUE; } else gi_320 = TRUE; gd_440 = 0; double ld_56 = (LosscutTrades - g_count_288) * PipsStep; double ld_64 = 5 * (LosscutTrades - 1) * LosscutTrades * (PipsStep / 10.0) + PipsStep * LosscutTrades; double ld_72 = 5 * g_count_288 * (g_count_288 + 1) * (PipsStep / 10.0); if (PipsStepPlus == FALSE) gd_440 = ld_56; if (PipsStepPlus == TRUE) { if (g_count_288 >= 1) gd_440 = ld_64 - ld_72; else gd_440 = ld_64; } gd_464 = 0; gd_456 = 0; gd_424 = 100.0 * gd_376; double ld_80 = 5 * g_count_288 * (g_count_288 + 1) * (PipsStep / 10.0); double ld_88 = 5 * g_count_288 * (g_count_288 + 1) * (PipsStep / 10.0) - PipsStep * gi_324; if (LotManagement) { if (g_count_288 < 2) gd_456 = ld_80; else gd_456 = ld_88; if (g_count_288 >= 1) gd_464 = gd_456 * (100.0 * gd_448) / (100.0 * g_ord_lots_416) / 2.9; else gd_464 = 20; } if (!LotManagement) { li_4 = FALSE; li_8 = g_count_288; if (g_count_288 >= 1) { if (PipsStepPlus == FALSE) for (g_pos_292 = 1; g_pos_292 <= g_count_288; g_pos_292++) li_4 = li_4 + PipsStep * g_pos_292; if (PipsStepPlus == TRUE) { li_12 = 0; for (g_pos_292 = 1; g_pos_292 <= li_8; g_pos_292++) { li_16 = 0; for (int li_96 = g_pos_292; li_96 <= li_8; li_96++) li_16 = li_16 + PipsStep * li_96; li_12 += li_16; } li_4 = li_12; } gd_464 = NormalizeDouble(li_4 / (gd_448 + gd_376) * Point + 20.0, 0); } else gd_464 = 20; } if (LSP_Turbo == TRUE) gi_328 = g_count_288; else gi_328 = TRUE; if (gi_304 == 1 && gi_472) { if (Bid - g_ord_open_price_392 >= PipsStep * gi_320 * Point || g_count_288 < 1) { g_price_368 = NormalizeDouble(Bid, 2); g_ord_open_price_392 = 0; if (gd_464 == 0.0) g_price_352 = 0; else g_price_352 = NormalizeDouble(g_price_368 - gd_464 * Point, 2); g_price_344 = NormalizeDouble(g_price_368 + gd_440 * Point, 2); g_lots_384 = gd_376; if (g_count_288 != 0) if (LotManagement) for (g_pos_292 = 1; g_pos_292 <= g_count_288; g_pos_292++) g_lots_384 = NormalizeDouble(g_lots_384 + LotStepPlus * gd_424 * gi_328, 2); if (g_lots_384 < ld_20) g_lots_384 = ld_20; if (g_lots_384 > ld_28) { g_lots_384 = ld_28; PlaySound("alert.wav"); MessageBox("!! The balance of the parameter setting value is not proper. The capital is to a set value and there is an excess possibility. !!"); } OrderSend(Symbol(), OP_SELL, g_lots_384, g_price_368, g_slippage_296, g_price_344, g_price_352, g_comment_280, g_magic_100, 0, Red); return (0); } } if (gi_304 == 2 && gi_472) { if (g_ord_open_price_392 - Ask >= PipsStep * gi_320 * Point || g_count_288 < 1) { g_price_360 = NormalizeDouble(Ask, 2); g_ord_open_price_392 = 0; if (gd_464 == 0.0) g_price_352 = 0; else g_price_352 = NormalizeDouble(g_price_360 + gd_464 * Point, 2); g_price_344 = NormalizeDouble(g_price_360 - gd_440 * Point, 2); g_lots_384 = gd_376; if (g_count_288 != 0) if (LotManagement) for (g_pos_292 = 1; g_pos_292 <= g_count_288; g_pos_292++) g_lots_384 = NormalizeDouble(g_lots_384 + LotStepPlus * gd_424 * gi_328, 2); if (g_lots_384 < ld_20) g_lots_384 = ld_20; if (g_lots_384 > ld_28) { g_lots_384 = ld_28; PlaySound("alert.wav"); MessageBox("!! The balance of the parameter setting value is not proper. The capital is to a set value and there is an excess possibility. !!"); } OrderSend(Symbol(), OP_BUY, g_lots_384, g_price_360, g_slippage_296, g_price_344, g_price_352, g_comment_280, g_magic_100, 0, Blue); return (0); } } return (0); } int Ind() { gi_304 = 3; double l_iclose_0 = iClose(NULL, 0, 1); double l_ima_8 = iMA(NULL, 0, MA_Period, 0, MODE_EMA, PRICE_CLOSE, 1); double l_imacd_16 = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, 1); double l_imacd_24 = iMACD(NULL, 0, FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_SIGNAL, 1); double l_icustom_32 = iCustom(NULL, 0, "ROC", RPeriod, UsePercent, 0, 1); double l_istochastic_40 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, 1); double l_istochastic_48 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_SIGNAL, 1); g_count_332 = 0; if (l_iclose_0 > l_ima_8) g_count_332++; else g_count_332--; if (l_imacd_16 > l_imacd_24) g_count_332++; else g_count_332--; if (l_icustom_32 > 0.0) g_count_332++; else g_count_332--; if (l_istochastic_40 > 50.0 && l_istochastic_48 > 50.0) g_count_332++; else g_count_332--; if (g_count_332 == -4) gi_304 = 1; if (g_count_332 == 4) gi_304 = 2; return (gi_304); } int LimitFunction() { if (TimeYear(TimeCurrent()) >= gi_76 + 1 || (TimeYear(TimeCurrent()) == gi_76 && TimeMonth(TimeCurrent()) > gi_80) || (TimeYear(TimeCurrent()) == gi_76 && TimeMonth(TimeCurrent()) == gi_80 && TimeDay(TimeCurrent()) > gi_84)) { Alert("Limit : " + gi_76 + "." + gi_80 + "." + gi_84); return (0); } return (1); } int CheckAccountFunction() { if (IsDemo()) return (1); for (int l_index_0 = 0; l_index_0 < 100; l_index_0++) if (AccountNumber() == gia_88[l_index_0]) return (1); return (0); }