#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が受けた損害を補填するものとする。"; extern int Magic = 2009002; extern double ManualLots = 0.01; extern bool MoneyManagement = TRUE; extern string AccCT = "1: AccCS 2: Manual"; extern int AccountControlType = 1; extern string AccCS = "AccCS Step for Multi Lots"; extern int AccountControlStep = 3200; extern string Type_PS = "1:Every PipsStep 2:PipsStep*OpenOrders"; extern int PipsStepType = 2; extern double PipsStep = 50.0; extern double LotStepPlus = 0.06; extern bool LSP_Turbo = TRUE; extern double TP_Offset = 1.0; extern int StopTrades = 4; extern int LosscutTrades = 4; extern bool TimeFilter = TRUE; extern int StopTime = 16; extern int StartTime = 20; 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; extern string ExpertVersion = "HPBW14"; int g_count_336 = 0; int g_pos_340 = 0; int g_slippage_344 = 5; int g_cmd_348 = OP_BUY; int gi_352 = 0; int gi_356 = 0; int g_ticket_360 = 0; int gi_364 = 0; int gi_368 = 0; int gi_372 = 0; int gi_376 = 0; int g_count_380 = 0; int gi_384 = 0; int gi_unused_388 = 0; int gi_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 gd_428 = 0.0; double g_lots_436 = 0.0; double g_ord_open_price_444 = 0.0; double gd_452 = 0.0; double g_price_460 = 0.0; double g_ord_lots_468 = 0.0; double gd_unused_476 = 0.0; double gd_484 = 0.0; double gd_492 = 0.0; double gd_500 = 0.0; double gd_508 = 0.0; double gd_516 = 0.0; double gd_524 = 0.0; double gd_unused_532 = 0.0; double gd_540 = 0.0; double gd_548 = 0.0; bool gi_556 = TRUE; 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_44; 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_500 = ld_0; MessageBox("!! The lot setting value is wrong. Please set it again. !!"); PlaySound("alert.wav"); } if (ManualLots >= ld_0) gd_500 = ManualLots; int li_32 = (AccountBalance() + AccountControlStep) / AccountControlStep; if (li_32 < 1) li_32 = 1; if (MoneyManagement) { switch (AccountControlType) { case 1: gd_428 = NormalizeDouble(gd_500 * li_32, 2); break; case 2: gd_428 = gd_500; break; default: gd_428 = gd_500; } switch (PipsStepType) { case 1: gi_368 = TRUE; break; case 2: gi_368 = g_count_336; break; default: gi_368 = TRUE; } } else gd_428 = gd_500; if (gd_428 < ld_0) gd_428 = ld_0; if (gd_428 > ld_8) gd_428 = ld_8; gi_392 = 0; if (SummerTimeTable) { l_datetime_44 = TimeCurrent(); if (TimeMonth(l_datetime_44) == 3) { if (TimeDay(l_datetime_44) <= 13) { if (DayOfWeek() == 0) gi_384 = TimeDay(l_datetime_44) + 7; if (DayOfWeek() == 1) gi_384 = TimeDay(l_datetime_44) + 6; if (DayOfWeek() == 2) gi_384 = TimeDay(l_datetime_44) + 5; if (DayOfWeek() == 3) gi_384 = TimeDay(l_datetime_44) + 4; if (DayOfWeek() == 4) gi_384 = TimeDay(l_datetime_44) + 3; if (DayOfWeek() == 5) gi_384 = TimeDay(l_datetime_44) + 2; if (DayOfWeek() == 6) gi_384 = TimeDay(l_datetime_44) + 1; if (gi_384 > 14) gi_392 = 1; } } if (TimeMonth(l_datetime_44) == 11) { if (TimeDay(l_datetime_44) >= 6) { if (DayOfWeek() == 0) gi_392 = 0; if (DayOfWeek() == 1) gi_384 = TimeDay(l_datetime_44) + 6; if (DayOfWeek() == 2) gi_384 = TimeDay(l_datetime_44) + 5; if (DayOfWeek() == 3) gi_384 = TimeDay(l_datetime_44) + 4; if (DayOfWeek() == 4) gi_384 = TimeDay(l_datetime_44) + 3; if (DayOfWeek() == 5) gi_384 = TimeDay(l_datetime_44) + 2; if (DayOfWeek() == 6) gi_384 = TimeDay(l_datetime_44) + 1; if (gi_384 < 8) gi_392 = 1; } } if (TimeMonth(l_datetime_44) > 3 || TimeMonth(l_datetime_44) < 11) gi_392 = 1; else gi_392 = 0; } g_count_336 = 0; gd_516 = 0; gi_372 = 0; for (g_pos_340 = 0; g_pos_340 < OrdersTotal(); g_pos_340++) { OrderSelect(g_pos_340, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { g_count_336++; gd_516 += OrderLots(); if (g_count_336 > 1) gi_372 += g_count_336 - 1; } } if (gi_356 > g_count_336) { for (g_pos_340 = OrdersTotal(); g_pos_340 >= 0; g_pos_340--) { OrderSelect(g_pos_340, SELECT_BY_POS, MODE_TRADES); g_cmd_348 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (g_cmd_348 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_344, Blue); if (g_cmd_348 == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_344, Red); return (0); } } } gi_356 = g_count_336; if (g_count_336 >= StopTrades) gi_556 = FALSE; else gi_556 = TRUE; if (g_ord_open_price_444 == 0.0) { for (g_pos_340 = 0; g_pos_340 < OrdersTotal(); g_pos_340++) { OrderSelect(g_pos_340, SELECT_BY_POS, MODE_TRADES); g_cmd_348 = OrderType(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { g_ord_open_price_444 = OrderOpenPrice(); if (g_cmd_348 == OP_BUY) gi_352 = 2; if (g_cmd_348 == OP_SELL) gi_352 = 1; } if (gd_548 == 0.0) gd_548 = AccountBalance(); } } if (g_count_336 < 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_392 && Hour() < StartTime - gi_392) { Comment("No trading, Working Time Filter"); return (0); } } if (StopTime > StartTime) { if (Hour() >= StopTime - gi_392 || Hour() < StartTime - gi_392) { Comment("No trading, Working Time Filter"); return (0); } } } gi_352 = Ind(); } gd_452 = 0; g_ticket_360 = 0; gi_364 = FALSE; g_price_460 = 0; g_ord_lots_468 = 0; for (g_pos_340 = 0; g_pos_340 < OrdersTotal(); g_pos_340++) { OrderSelect(g_pos_340, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { g_ticket_360 = OrderTicket(); if (OrderType() == OP_BUY) gi_364 = FALSE; if (OrderType() == OP_SELL) gi_364 = TRUE; g_price_460 = OrderClosePrice(); g_ord_lots_468 = OrderLots(); if (gi_364 == FALSE) { if (OrderClosePrice() < OrderOpenPrice()) gd_452 -= (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; if (OrderClosePrice() > OrderOpenPrice()) gd_452 += (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; } if (gi_364 == TRUE) { if (OrderClosePrice() > OrderOpenPrice()) gd_452 -= (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point; if (OrderClosePrice() < OrderOpenPrice()) gd_452 += (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point; } } } gd_484 = 100.0 * gd_428 * TP_Offset; if (g_count_336 != 0) gd_452 = gd_452 / gd_484 * l_tickvalue_24; if (g_count_336 >= 1) { if (gd_452 >= (gd_548 * (TP_Offset / 1000.0) && MoneyManagement) || (gd_452 >= gd_428 * (ld_16 / 100.0) && !MoneyManagement)) { OrderClose(g_ticket_360, g_ord_lots_468, g_price_460, g_slippage_344, Yellow); gi_556 = FALSE; return (0); } } if (!IsTesting()) Comment("TotalLots = ", gd_516, " Open Order Delay Until Loss Cut = ", LosscutTrades - g_count_336, " TP Monitor = ", gd_452 - gd_548 * TP_Offset / 1000.0); gd_508 = 0; gd_540 = 0; double ld_48 = (LosscutTrades - g_count_336) * PipsStep; double ld_56 = 5 * (LosscutTrades - 1) * LosscutTrades * (PipsStep / 10.0) + PipsStep * LosscutTrades; double ld_64 = 5 * g_count_336 * (g_count_336 + 1) * (PipsStep / 10.0); if (PipsStepType == 1) gd_508 = ld_48; if (PipsStepType == 2) { if (g_count_336 >= 1) gd_508 = ld_56 - ld_64; else gd_508 = ld_56; if (g_count_336 < 2) gi_368 = TRUE; } gd_524 = 0; gd_492 = 100.0 * gd_428; double ld_72 = 5 * g_count_336 * (g_count_336 + 1) * (PipsStep / 10.0); double ld_80 = 5 * g_count_336 * (g_count_336 + 1) * (PipsStep / 10.0) - PipsStep * gi_372; if (g_count_336 < 2) gd_524 = ld_72; else gd_524 = ld_80; if (g_count_336 >= 1) gd_540 = gd_524 * (100.0 * gd_516) / (100.0 * g_ord_lots_468) / 2.9; else gd_540 = 20; if (LSP_Turbo == TRUE) gi_376 = g_count_336; else gi_376 = TRUE; if (gi_352 == 1 && gi_556) { if (Bid - g_ord_open_price_444 >= PipsStep * gi_368 * Point || g_count_336 < 1) { if (g_count_336 < 1) gd_548 = AccountBalance(); g_bid_420 = Bid; g_ord_open_price_444 = 0; g_price_404 = NormalizeDouble(g_bid_420 - gd_540 * Point, Digits); g_price_396 = NormalizeDouble(g_bid_420 + gd_508 * Point, Digits); if (g_count_336 != 0) { g_lots_436 = gd_428; for (g_pos_340 = 1; g_pos_340 <= g_count_336; g_pos_340++) { if (LosscutTrades > 10) { g_lots_436 = NormalizeDouble(1.5 * g_lots_436, 2); MessageBox("!! Too Much Set of LosscutTrades on Parameter. Please set it again. !!"); PlaySound("alert.wav"); } else g_lots_436 = NormalizeDouble(g_lots_436 + LotStepPlus * gd_492 * gi_376, 2); } } else g_lots_436 = gd_428; if (g_lots_436 > 100.0) g_lots_436 = 100; OrderSend(Symbol(), OP_SELL, g_lots_436, g_bid_420, g_slippage_344, g_price_396, g_price_404, ExpertVersion, Magic, 0, Red); return (0); } } if (gi_352 == 2 && gi_556) { if (g_ord_open_price_444 - Ask >= PipsStep * gi_368 * Point || g_count_336 < 1) { if (g_count_336 < 1) gd_548 = AccountBalance(); g_ask_412 = Ask; g_ord_open_price_444 = 0; g_price_404 = NormalizeDouble(g_ask_412 + gd_540 * Point, Digits); g_price_396 = NormalizeDouble(g_ask_412 - gd_508 * Point, Digits); if (g_count_336 != 0) { g_lots_436 = gd_428; for (g_pos_340 = 1; g_pos_340 <= g_count_336; g_pos_340++) { if (LosscutTrades > 10) { g_lots_436 = NormalizeDouble(1.5 * g_lots_436, 2); MessageBox("!! Too Much Set of LosscutTrades on Parameter. Please set it again. !!"); PlaySound("alert.wav"); } else g_lots_436 = NormalizeDouble(g_lots_436 + LotStepPlus * gd_492 * gi_376, 2); } } else g_lots_436 = gd_428; if (g_lots_436 > 100.0) g_lots_436 = 100; OrderSend(Symbol(), OP_BUY, g_lots_436, g_ask_412, g_slippage_344, g_price_396, g_price_404, ExpertVersion, Magic, 0, Blue); return (0); } } return (0); } int Ind() { gi_352 = 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_380 = 0; if (l_iclose_0 > l_ima_8) g_count_380++; else g_count_380--; if (l_imacd_16 > l_imacd_24) g_count_380++; else g_count_380--; if (l_icustom_32 > 0.0) g_count_380++; else g_count_380--; if (l_istochastic_40 > 50.0 && l_istochastic_48 > 50.0) g_count_380++; else g_count_380--; if (g_count_380 == -4) gi_352 = 1; if (g_count_380 == 4) gi_352 = 2; return (gi_352); }