#property copyright "Copyright ゥ 2009 YA" #property link "" #include bool gi_76 = FALSE; bool gi_80 = FALSE; string gs_unused_84 = "第3条禁止止事項"; string gs_unused_92 = "1.お客様が本製品を譲渡、販売、転貸すること。"; string gs_unused_100 = "2.お客様がバックアップを目的とする以外に本製品を複製すること。"; string gs_unused_108 = "3.お客様が本製品をリバースエンジニアリング、逆コンパイル、または逆アセンブルすること。"; string gs_unused_116 = "4.お客様が本ソ\フトウェアの技術的な制限を回避して使用すること。"; string gs_unused_124 = "5.お客様が本条1項から4項までの禁止行為を行った場合、お客様はfx-on.comに対しfx-on.comが受けた損害を補填するものとする。"; int g_magic_132 = 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 = TRUE; extern string MovingAverage = "--------------------------"; extern double MA_Period = 20.0; extern string MACD = "--------------------------"; extern int FastEMA = 12; extern int SlowEMA = 26; extern int SignalSMA = 9; extern string ROC = "--------------------------"; extern int RPeriod = 14; extern bool UsePercent = TRUE; extern string Stochastic = "--------------------------"; extern int KPeriod = 14; extern int DPeriod = 3; extern int Slowing = 3; string g_comment_344 = "HPBW14_Ver3.0.1"; int g_count_352 = 0; int g_pos_356 = 0; int g_slippage_360 = 5; int g_cmd_364 = OP_BUY; int gi_368 = 0; int gi_372 = 0; int g_ticket_376 = 0; int gi_380 = 0; int gi_384 = 0; int gi_388 = 0; int gi_392 = 0; int g_count_396 = 0; int gi_400 = 0; int gi_404 = 0; double g_price_408 = 0.0; double g_price_416 = 0.0; double g_ask_424 = 0.0; double g_bid_432 = 0.0; double gd_440 = 0.0; double g_lots_448 = 0.0; double g_ord_open_price_456 = 0.0; double gd_464 = 0.0; double g_price_472 = 0.0; double g_ord_lots_480 = 0.0; double gd_488 = 0.0; double gd_496 = 0.0; double gd_504 = 0.0; double gd_512 = 0.0; double gd_520 = 0.0; double gd_528 = 0.0; double gd_536 = 0.0; bool gi_544 = TRUE; string gs_548 = ""; int init() { gi_76 = AccountCertification(); gi_80 = DateCertification(); if (gi_76) Print("Account setting was approved."); if (gi_80) Print("Date setting was approved."); return (0); } int deinit() { return (0); } int start() { int l_datetime_36; bool li_80; int li_84; int li_88; int li_92; if (!gi_76) { Comment("\nTrading is not allowed. Wrong account : " + AccountNumber()); return (0); } if (!gi_80) { Comment("\nDate is invalid."); return (0); } double ld_0 = NormalizeDouble(MarketInfo(Symbol(), MODE_MINLOT), 2); double ld_8 = NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT), 2); double ld_16 = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSIZE), 0); double l_tickvalue_24 = MarketInfo(Symbol(), MODE_TICKVALUE); if (ManualLots < ld_0) { gd_496 = ld_0; PlaySound("alert.wav"); MessageBox("!! The lot setting value is wrong. Please set it again. !!"); } if (ManualLots >= ld_0) gd_496 = ManualLots; int li_32 = (AccountBalance() + LotControlStep) / LotControlStep; if (li_32 < 1) li_32 = 1; if (LotManagement) gd_440 = NormalizeDouble(gd_496 * li_32, 2); else gd_440 = gd_496; if (gd_440 < ld_0) gd_440 = ld_0; if (gd_440 > ld_8) gd_440 = ld_8; gi_404 = 0; if (SummerTimeTable) { l_datetime_36 = TimeCurrent(); if (TimeMonth(l_datetime_36) == 3) { if (TimeDay(l_datetime_36) <= 13) { if (DayOfWeek() == 0) gi_400 = TimeDay(l_datetime_36) + 7; if (DayOfWeek() == 1) gi_400 = TimeDay(l_datetime_36) + 6; if (DayOfWeek() == 2) gi_400 = TimeDay(l_datetime_36) + 5; if (DayOfWeek() == 3) gi_400 = TimeDay(l_datetime_36) + 4; if (DayOfWeek() == 4) gi_400 = TimeDay(l_datetime_36) + 3; if (DayOfWeek() == 5) gi_400 = TimeDay(l_datetime_36) + 2; if (DayOfWeek() == 6) gi_400 = TimeDay(l_datetime_36) + 1; if (gi_400 > 14) gi_404 = 1; } } if (TimeMonth(l_datetime_36) == 11) { if (TimeDay(l_datetime_36) >= 6) { if (DayOfWeek() == 0) gi_404 = 0; if (DayOfWeek() == 1) gi_400 = TimeDay(l_datetime_36) + 6; if (DayOfWeek() == 2) gi_400 = TimeDay(l_datetime_36) + 5; if (DayOfWeek() == 3) gi_400 = TimeDay(l_datetime_36) + 4; if (DayOfWeek() == 4) gi_400 = TimeDay(l_datetime_36) + 3; if (DayOfWeek() == 5) gi_400 = TimeDay(l_datetime_36) + 2; if (DayOfWeek() == 6) gi_400 = TimeDay(l_datetime_36) + 1; if (gi_400 < 8) gi_404 = 1; } } if (TimeMonth(l_datetime_36) > 3 || TimeMonth(l_datetime_36) < 11) gi_404 = 1; else gi_404 = 0; } g_count_352 = 0; gd_512 = 0; gi_388 = 0; for (g_pos_356 = 0; g_pos_356 < OrdersTotal(); g_pos_356++) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_132) { g_count_352++; gd_512 += OrderLots(); if (g_count_352 > 1) gi_388 = gi_388 + g_count_352 - 1; } } if (gi_372 > g_count_352) { for (g_pos_356 = OrdersTotal(); g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); g_cmd_364 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_132) { if (g_cmd_364 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_360, Blue); if (g_cmd_364 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_360, Red); return (0); } } } gi_372 = g_count_352; if (g_count_352 >= StopTrades) gi_544 = FALSE; else gi_544 = TRUE; if (g_ord_open_price_456 == 0.0) { for (g_pos_356 = 0; g_pos_356 < OrdersTotal(); g_pos_356++) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); g_cmd_364 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_132) { g_ord_open_price_456 = OrderOpenPrice(); if (g_cmd_364 == OP_BUY) gi_368 = 2; if (g_cmd_364 == OP_SELL) gi_368 = 1; } } } if (g_count_352 != 0 && gd_536 == 0.0) gd_536 = AccountBalance(); if (g_count_352 < 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_404 && Hour() < StartTime - gi_404) { Comment("No trading, Working Time Filter"); return (0); } } if (StopTime > StartTime) { if (Hour() >= StopTime - gi_404 || Hour() < StartTime - gi_404) { Comment("No trading, Working Time Filter"); return (0); } } } gi_368 = Ind(); } gd_464 = 0; g_ticket_376 = 0; gi_380 = FALSE; g_price_472 = 0; g_ord_lots_480 = 0; for (g_pos_356 = 0; g_pos_356 < OrdersTotal(); g_pos_356++) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_132) { g_ticket_376 = OrderTicket(); if (OrderType() == OP_BUY) gi_380 = FALSE; if (OrderType() == OP_SELL) gi_380 = TRUE; g_price_472 = OrderClosePrice(); g_ord_lots_480 = OrderLots(); if (gi_380 == FALSE) { if (OrderClosePrice() < OrderOpenPrice()) gd_464 -= (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; if (OrderClosePrice() > OrderOpenPrice()) gd_464 += (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; } if (gi_380 == TRUE) { if (OrderClosePrice() > OrderOpenPrice()) gd_464 -= (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; if (OrderClosePrice() < OrderOpenPrice()) gd_464 += (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; } } } gd_464 *= l_tickvalue_24; if (g_count_352 >= 1) { if (gd_464 >= gd_440 * (ld_16 / 1000.0) * TP_Offset) { OrderClose(g_ticket_376, g_ord_lots_480, g_price_472, g_slippage_360, Yellow); gi_544 = FALSE; return (0); } } if (FridayFilter) { if (FridayStopTime <= FridayStartTime) { if (FridayStopTime == 0 && gi_404 != 0) { if (DayOfWeek() >= 5 && Hour() >= 23 || Hour() < FridayStartTime - gi_404) { Comment("No trading, Working Friday Filter"); return (0); } } else { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_404 && Hour() < FridayStartTime - gi_404) { Comment("No trading, Working Friday Filter"); return (0); } } } if (FridayStopTime > FridayStartTime) { if (FridayStartTime == 0 && gi_404 != 0) { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_404 && Hour() < 23) { Comment("No trading, Working Friday Filter"); return (0); } } else { if (DayOfWeek() >= 5 && Hour() >= FridayStopTime - gi_404 || Hour() < FridayStartTime - gi_404) { Comment("No trading, Working Friday Filter"); return (0); } } } } if (!IsTesting()) { if (gi_368 == 3) gs_548 = "The trading signal is waited for"; else gs_548 = gd_464 - gd_440 * (ld_16 / 1000.0) * TP_Offset; Comment(" >>>>> ", AccountCompany(), "\n >>>>> TotalLots = ", gd_512, "\n >>>>> Open Order Delay Until Loss Cut = ", LosscutTrades - g_count_352, "\n >>>>> Monitor ", gs_548); } if (PipsStepPlus == TRUE) { if (g_count_352 >= 2) gi_384 = g_count_352; if (g_count_352 <= 1) gi_384 = TRUE; } else gi_384 = TRUE; gd_504 = 0; double ld_40 = (LosscutTrades - g_count_352) * PipsStep; double ld_48 = 5 * (LosscutTrades - 1) * LosscutTrades * (PipsStep / 10.0) + PipsStep * LosscutTrades; double ld_56 = 5 * g_count_352 * (g_count_352 + 1) * (PipsStep / 10.0); if (PipsStepPlus == FALSE) gd_504 = ld_40; if (PipsStepPlus == TRUE) { if (g_count_352 >= 1) gd_504 = ld_48 - ld_56; else gd_504 = ld_48; } gd_528 = 0; gd_520 = 0; gd_488 = 100.0 * gd_440; double ld_64 = 5 * g_count_352 * (g_count_352 + 1) * (PipsStep / 10.0); double ld_72 = 5 * g_count_352 * (g_count_352 + 1) * (PipsStep / 10.0) - PipsStep * gi_388; if (LotManagement) { if (g_count_352 < 2) gd_520 = ld_64; else gd_520 = ld_72; if (g_count_352 >= 1) gd_528 = gd_520 * (100.0 * gd_512) / (100.0 * g_ord_lots_480) / 2.9; else gd_528 = 20; } if (!LotManagement) { li_80 = FALSE; li_84 = g_count_352; if (g_count_352 >= 1) { if (PipsStepPlus == FALSE) for (g_pos_356 = 1; g_pos_356 <= g_count_352; g_pos_356++) li_80 = li_80 + PipsStep * g_pos_356; if (PipsStepPlus == TRUE) { li_88 = 0; for (g_pos_356 = 1; g_pos_356 <= li_84; g_pos_356++) { li_92 = 0; for (int li_96 = g_pos_356; li_96 <= li_84; li_96++) li_92 = li_92 + PipsStep * li_96; li_88 += li_92; } li_80 = li_88; } gd_528 = NormalizeDouble(li_80 / (gd_512 + gd_440) * Point + 20.0, 0); } else gd_528 = 20; } if (LSP_Turbo == TRUE) gi_392 = g_count_352; else gi_392 = TRUE; if (gi_368 == 1 && gi_544) { if (Bid - g_ord_open_price_456 >= PipsStep * gi_384 * Point || g_count_352 < 1) { if (g_count_352 < 1) gd_536 = AccountBalance(); g_bid_432 = Bid; g_ord_open_price_456 = 0; if (gd_528 == 0.0) g_price_416 = 0; else g_price_416 = NormalizeDouble(g_bid_432 - gd_528 * Point, Digits); g_price_408 = NormalizeDouble(g_bid_432 + gd_504 * Point, Digits); g_lots_448 = gd_440; if (g_count_352 != 0) if (LotManagement) for (g_pos_356 = 1; g_pos_356 <= g_count_352; g_pos_356++) g_lots_448 = NormalizeDouble(g_lots_448 + LotStepPlus * gd_488 * gi_392, 2); if (g_lots_448 < ld_0) g_lots_448 = ld_0; if (g_lots_448 > ld_8) { g_lots_448 = ld_8; 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_448, g_bid_432, g_slippage_360, g_price_408, g_price_416, g_comment_344, g_magic_132, 0, Red); return (0); } } if (gi_368 == 2 && gi_544) { if (g_ord_open_price_456 - Ask >= PipsStep * gi_384 * Point || g_count_352 < 1) { if (g_count_352 < 1) gd_536 = AccountBalance(); g_ask_424 = Ask; g_ord_open_price_456 = 0; if (gd_528 == 0.0) g_price_416 = 0; else g_price_416 = NormalizeDouble(g_ask_424 + gd_528 * Point, Digits); g_price_408 = NormalizeDouble(g_ask_424 - gd_504 * Point, Digits); g_lots_448 = gd_440; if (g_count_352 != 0) if (LotManagement) for (g_pos_356 = 1; g_pos_356 <= g_count_352; g_pos_356++) g_lots_448 = NormalizeDouble(g_lots_448 + LotStepPlus * gd_488 * gi_392, 2); if (g_lots_448 < ld_0) g_lots_448 = ld_0; if (g_lots_448 > ld_8) { g_lots_448 = ld_8; 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_448, g_ask_424, g_slippage_360, g_price_408, g_price_416, g_comment_344, g_magic_132, 0, Blue); return (0); } } return (0); } int Ind() { gi_368 = 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_396 = 0; if (l_iclose_0 > l_ima_8) g_count_396++; else g_count_396--; if (l_imacd_16 > l_imacd_24) g_count_396++; else g_count_396--; if (l_icustom_32 > 0.0) g_count_396++; else g_count_396--; if (l_istochastic_40 > 50.0 && l_istochastic_48 > 50.0) g_count_396++; else g_count_396--; if (g_count_396 == -4) gi_368 = 1; if (g_count_396 == 4) gi_368 = 2; return (gi_368); }