double g_pips_76 = 5000.0; double gd_84 = 100.0; double gd_92 = 100.0; double gd_100 = 20.0; double gd_108 = 48.0; double g_slippage_116 = 5.0; bool gi_124 = FALSE; bool gi_128 = FALSE; bool gi_132 = FALSE; extern int PauseMin = 10; extern int MaxTrades = 10; extern int magic = 12324; extern int lotdecimal = 2; extern double Lots = 0.01; extern double PercentLots = 2.0; extern double LotExponent = 1.59; extern double TakeProfit = 12.0; extern double PipStep = 30.0; extern bool TimeFilter = TRUE; extern double EndHour = 13.0; extern double StartHour = 15.0; double g_price_212; double gd_220; double gd_unused_228; double gd_unused_236; double g_price_244; double g_bid_252; double g_ask_260; double gd_268; double gd_276; double gd_284; double gd_292; double gd_300 = 0.0; double gd_308; double gd_316; bool gi_324; bool gi_328 = FALSE; bool gi_332 = FALSE; bool gi_336 = FALSE; bool gi_340 = FALSE; int g_time_344 = 0; int gi_348; int gi_352 = 0; int g_pos_356 = 0; int gi_360; int gi_364; string gs_368 = "BostonEAPRO v11.0"; int g_hist_total_376; int gi_unused_380; int gi_384; int gi_388; int gi_392; int gi_396; int init() { gd_284 = MarketInfo(Symbol(), MODE_SPREAD) * Point; return (0); } int deinit() { return (0); } int TradeTime() { int l_datetime_0; double l_ord_profit_4; if (g_hist_total_376 == OrdersHistoryTotal()) return (0); for (int l_pos_12 = OrdersHistoryTotal() + 1; l_pos_12 >= 0; l_pos_12--) { if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == Symbol()) { if (OrderCloseTime() > l_datetime_0) { l_datetime_0 = OrderCloseTime(); l_ord_profit_4 = OrderProfit(); } } } } if (l_ord_profit_4 > 0.0) { if (TimeCurrent() - l_datetime_0 >= 60 * PauseMin) { g_hist_total_376 = OrdersHistoryTotal(); return (1); } return (0); } return (0); } int start() { int li_0 = 1616789; int l_acc_number_4 = AccountNumber(); if (l_acc_number_4 != li_0) { Alert("You can not use this account (" + DoubleToStr(l_acc_number_4, 0) + ") with this program!"); return (0); } double l_icustom_8 = iCustom(Symbol(), PERIOD_H1, "ZigZag_NK", 16, 5, 3, 0, 0); double l_icustom_16 = iCustom(Symbol(), PERIOD_H1, "ZigZag_NK", 16, 5, 3, 1, 0); if (l_icustom_8 < l_icustom_16) gi_unused_380 = -1; else if (l_icustom_16 < l_icustom_8) gi_unused_380 = 1; double l_icustom_24 = iCustom(Symbol(), PERIOD_M15, "ZigZag_NK", 16, 5, 3, 0, 0); double l_icustom_32 = iCustom(Symbol(), PERIOD_M15, "ZigZag_NK", 16, 5, 3, 1, 0); if (l_icustom_24 < l_icustom_32) gi_384 = -1; else if (l_icustom_32 < l_icustom_24) gi_384 = 1; double l_icustom_40 = iCustom(Symbol(), PERIOD_M5, "ZigZag_NK", 16, 5, 3, 0, 0); double l_icustom_48 = iCustom(Symbol(), PERIOD_M5, "ZigZag_NK", 16, 5, 3, 1, 0); if (l_icustom_40 > l_icustom_48) gi_388 = -1; else if (l_icustom_48 > l_icustom_40) gi_388 = 1; double l_icustom_56 = iCustom(Symbol(), PERIOD_M1, "ZigZag_NK", 16, 5, 3, 0, 0); double l_icustom_64 = iCustom(Symbol(), PERIOD_M1, "ZigZag_NK", 16, 5, 3, 1, 0); if (l_icustom_56 > l_icustom_64) gi_392 = -1; else if (l_icustom_64 > l_icustom_56) gi_392 = 1; double l_icustom_72 = iCustom(Symbol(), PERIOD_M5, "VininI_HMA", 23, 3, 0, 0, 0, 0); double l_icustom_80 = iCustom(Symbol(), PERIOD_M5, "VininI_HMA", 23, 3, 0, 0, 1, 0); double l_icustom_88 = iCustom(Symbol(), PERIOD_M5, "VininI_HMA", 23, 3, 0, 0, 2, 0); if (l_icustom_80 != EMPTY_VALUE) gi_396 = 1; else { if (l_icustom_88 != EMPTY_VALUE) gi_396 = -1; else if (l_icustom_72 != EMPTY_VALUE) gi_396 = 0; } if (gi_124) TrailingAlls(gd_84, gd_92, g_price_244); if (gi_132) { if (TimeCurrent() >= gi_348) { CloseThisSymbolAll(); Print("Closed All due to TimeOut"); } } if (!TradeTime()) if (g_time_344 == Time[0]) return (0); g_time_344 = Time[0]; double ld_96 = CalculateProfit(); if (gi_128) { if (ld_96 < 0.0 && MathAbs(ld_96) > gd_100 / 100.0 * AccountEquityHigh()) { CloseThisSymbolAll(); Print("Closed All due to Stop Out"); gi_340 = FALSE; } } gi_360 = CountTrades(); if (gi_360 == 0) gi_324 = FALSE; for (g_pos_356 = OrdersTotal() - 1; g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_BUY) { gi_332 = TRUE; gi_336 = FALSE; break; } } if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_SELL) { gi_332 = FALSE; gi_336 = TRUE; break; } } } if (gi_360 > 0 && gi_360 <= MaxTrades) { RefreshRates(); gd_268 = FindLastBuyPrice(); gd_276 = FindLastSellPrice(); if (gi_332 && gd_268 - Ask >= PipStep * Point && gi_384 < 0 && gi_392 < 0 && gi_396 <= 0) gi_328 = TRUE; if (gi_336 && Bid - gd_276 >= PipStep * Point && gi_384 > 0 && gi_392 > 0 && gi_396 >= 0) gi_328 = TRUE; } if (gi_360 < 1) { gi_336 = FALSE; gi_332 = FALSE; gi_328 = TRUE; gd_220 = AccountEquity(); } if (gi_328) { gd_268 = FindLastBuyPrice(); gd_276 = FindLastSellPrice(); if (gi_336) { gi_352 = gi_360; gd_292 = NormalizeDouble(GetLots() * MathPow(LotExponent, gi_352), lotdecimal); RefreshRates(); gi_364 = OpenPendingOrder(1, gd_292, Bid, g_slippage_116, Ask, 0, 0, gs_368 + "-" + gi_352, magic, 0, Red); if (gi_364 < 0) { Print("Error: ", GetLastError()); return (0); } gd_276 = FindLastSellPrice(); gi_328 = FALSE; gi_340 = TRUE; } else { if (gi_332) { gi_352 = gi_360; gd_292 = NormalizeDouble(GetLots() * MathPow(LotExponent, gi_352), lotdecimal); gi_364 = OpenPendingOrder(0, gd_292, Ask, g_slippage_116, Bid, 0, 0, gs_368 + "-" + gi_352, magic, 0, Blue); if (gi_364 < 0) { Print("Error: ", GetLastError()); return (0); } gd_268 = FindLastBuyPrice(); gi_328 = FALSE; gi_340 = TRUE; } } } if (gi_328 && gi_360 < 1) { g_bid_252 = Bid; g_ask_260 = Ask; if (!gi_336 && !gi_332) { gi_352 = gi_360; gd_292 = NormalizeDouble(GetLots() * MathPow(LotExponent, gi_352), lotdecimal); if (TimeFilter == TRUE && Hour() >= EndHour && Hour() < StartHour) return (0); if (gi_388 > 0) { gi_364 = OpenPendingOrder(1, gd_292, g_bid_252, g_slippage_116, g_bid_252, 0, 0, gs_368 + "-" + gi_352, magic, 0, Red); if (gi_364 < 0) { Print("Error: ", GetLastError()); return (0); } gd_268 = FindLastBuyPrice(); gi_340 = TRUE; } if (gi_388 < 0) { gi_364 = OpenPendingOrder(0, gd_292, g_ask_260, g_slippage_116, g_ask_260, 0, 0, gs_368 + "-" + gi_352, magic, 0, Blue); if (gi_364 < 0) { Print("Error: ", GetLastError()); return (0); } gd_276 = FindLastSellPrice(); gi_340 = TRUE; } if (gi_364 > 0) gi_348 = TimeCurrent() + 60.0 * (60.0 * gd_108); gi_328 = FALSE; } } gi_360 = CountTrades(); g_price_244 = 0; double ld_104 = 0; for (g_pos_356 = OrdersTotal() - 1; g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) { g_price_244 += OrderOpenPrice() * OrderLots(); ld_104 += OrderLots(); } } } if (gi_360 > 0) g_price_244 = NormalizeDouble(g_price_244 / ld_104, Digits); if (gi_340) { for (g_pos_356 = OrdersTotal() - 1; g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_BUY) { g_price_212 = g_price_244 + TakeProfit * Point; gd_unused_228 = g_price_212; gd_300 = g_price_244 - g_pips_76 * Point; gi_324 = TRUE; } } if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_SELL) { g_price_212 = g_price_244 - TakeProfit * Point; gd_unused_236 = g_price_212; gd_300 = g_price_244 + g_pips_76 * Point; gi_324 = TRUE; } } } } if (gi_340) { if (gi_324 == TRUE) { for (g_pos_356 = OrdersTotal() - 1; g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) OrderModify(OrderTicket(), g_price_244, OrderStopLoss(), g_price_212, 0, Yellow); gi_340 = FALSE; } } } return (0); } int CountTrades() { int l_count_0 = 0; for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_0++; } return (l_count_0); } void CloseThisSymbolAll() { for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) { if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_116, Blue); if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_116, Red); } Sleep(1000); } } } int OpenPendingOrder(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) { int l_ticket_60 = 0; int l_error_64 = 0; int l_count_68 = 0; int li_72 = 100; switch (ai_0) { case 2: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(1000); } break; case 4: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(5000); } break; case 0: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { RefreshRates(); l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(5000); } break; case 3: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(5000); } break; case 5: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(5000); } break; case 1: for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); l_error_64 = GetLastError(); if (l_error_64 == 0/* NO_ERROR */) break; if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break; Sleep(5000); } } return (l_ticket_60); } double StopLong(double ad_0, int ai_8) { if (ai_8 == 0) return (0); return (ad_0 - ai_8 * Point); } double StopShort(double ad_0, int ai_8) { if (ai_8 == 0) return (0); return (ad_0 + ai_8 * Point); } double TakeLong(double ad_0, int ai_8) { if (ai_8 == 0) return (0); return (ad_0 + ai_8 * Point); } double TakeShort(double ad_0, int ai_8) { if (ai_8 == 0) return (0); return (ad_0 - ai_8 * Point); } double CalculateProfit() { double ld_ret_0 = 0; for (g_pos_356 = OrdersTotal() - 1; g_pos_356 >= 0; g_pos_356--) { OrderSelect(g_pos_356, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit(); } return (ld_ret_0); } void TrailingAlls(int ai_0, int ai_4, double a_price_8) { int li_16; double l_ord_stoploss_20; double l_price_28; if (ai_4 != 0) { for (int l_pos_36 = OrdersTotal() - 1; l_pos_36 >= 0; l_pos_36--) { if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() || OrderMagicNumber() == magic) { if (OrderType() == OP_BUY) { li_16 = NormalizeDouble((Bid - a_price_8) / Point, 0); if (li_16 < ai_0) continue; l_ord_stoploss_20 = OrderStopLoss(); l_price_28 = Bid - ai_4 * Point; if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua); } if (OrderType() == OP_SELL) { li_16 = NormalizeDouble((a_price_8 - Ask) / Point, 0); if (li_16 < ai_0) continue; l_ord_stoploss_20 = OrderStopLoss(); l_price_28 = Ask + ai_4 * Point; if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red); } } Sleep(1000); } } } } double AccountEquityHigh() { if (CountTrades() == 0) gd_308 = AccountEquity(); if (gd_308 < gd_316) gd_308 = gd_316; else gd_308 = AccountEquity(); gd_316 = AccountEquity(); return (gd_308); } double FindLastBuyPrice() { double l_ord_open_price_0; int l_ticket_8; double ld_unused_12 = 0; int l_ticket_20 = 0; for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) { OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_BUY) { l_ticket_8 = OrderTicket(); if (l_ticket_8 > l_ticket_20) { l_ord_open_price_0 = OrderOpenPrice(); ld_unused_12 = l_ord_open_price_0; l_ticket_20 = l_ticket_8; } } } return (l_ord_open_price_0); } double FindLastSellPrice() { double l_ord_open_price_0; int l_ticket_8; double ld_unused_12 = 0; int l_ticket_20 = 0; for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) { OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_SELL) { l_ticket_8 = OrderTicket(); if (l_ticket_8 > l_ticket_20) { l_ord_open_price_0 = OrderOpenPrice(); ld_unused_12 = l_ord_open_price_0; l_ticket_20 = l_ticket_8; } } } return (l_ord_open_price_0); } double GetLots() { double ld_ret_16; double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT); double l_maxlot_8 = MarketInfo(Symbol(), MODE_MAXLOT); if (PercentLots != 0.0) { ld_ret_16 = NormalizeDouble(AccountBalance() * PercentLots / 1000.0 / 100.0, 2); if (ld_ret_16 < l_minlot_0) ld_ret_16 = l_minlot_0; if (ld_ret_16 > l_maxlot_8) ld_ret_16 = l_maxlot_8; } else ld_ret_16 = Lots; return (ld_ret_16); }