#property copyright "Copyright © duuble team " #property link "http://www.metaquotes.net" extern string MM = "---------------- Money Management"; extern double MinProfit = 0.0; extern double Multiplier = 2.0; extern double LotsBuy = 0.01; extern double LotsSell = 0.01; extern bool RiskMM = FALSE; extern double Risk = 1.0; extern string OM = "---------------- Order Management"; extern double TakeProfit = 0.0; extern bool UseAutomatedTP = TRUE; extern double AutomatedTPFactor = 10.0; extern double StopLoss = 0.0; extern double TrailingStop = 0.0; extern double TrailingStopStep = 1.0; extern bool UseMaxSpread = FALSE; extern int MaxSpread = 2; extern int Slippage = 3; extern bool MaxOpenOrders = FALSE; extern int MaxBuyOrders = 100; extern int MaxSellOrders = 100; extern bool UseEquityTarget = FALSE; extern int EquityTarget = 15000; extern bool UseEquityLoss = FALSE; extern int EquityLoss = 8000; extern string DBO = "---------------- Distance between orders"; extern double Step = 25.0; extern int StepMode = 0; extern string SS = "---------------- Stochastic Settings"; extern double KPeriod = 200.0; extern double DPeriod = 20.0; extern double Slowing = 20.0; extern double SimpleZoneBuy = 50.0; extern double SimpleZoneSell = 50.0; extern bool ExtendedZone = FALSE; extern double CloseLevelUpBuy = 70.0; extern double EndZoneBuy = 20.0; extern double StartZoneBuy = 0.0; extern double CloseLevelDnBuy = 0.0; extern double CloseLevelUpSell = 100.0; extern double EndZoneSell = 100.0; extern double StartZoneSell = 70.0; extern double CloseLevelDnSell = 20.0; extern string MAF = "---------------- MA Filter Settings"; extern bool MaFilter = FALSE; extern double MaPeriod = 200.0; extern double MaMode = 1.0; extern double MaPrice = 0.0; extern string TAF = "---------------- Time Filter Settings"; extern bool TimeFilter = FALSE; extern double StartHour = 8.0; extern double EndHour = 21.0; extern bool CloseFriday = FALSE; extern double CloseFridayHour = 22.0; double g_magic_432 = 555.0; double g_magic_440 = 556.0; double g_ord_open_price_448; double g_ord_open_price_456; double g_ord_lots_464; double g_ord_lots_472; double g_ord_lots_480; double g_ord_lots_488; double g_price_496; double g_price_504; double g_price_512; double g_price_520; double g_price_528; double g_price_536; double g_pos_544; double g_ord_stoploss_552; double g_ord_stoploss_560; double gd_592; double g_free_magrin_600; double gd_608; double gd_632; double gd_672 = 0.0; int gi_unused_680 = 0; int g_ticket_684; int g_ticket_688; int gi_692 = 152088; int OrdersTotalMagicBuy(int a_magic_0) { int l_count_4 = 0; for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) if (OrderMagicNumber() == a_magic_0) l_count_4++; } return (l_count_4); } int OrdersTotalMagicSell(int a_magic_0) { int l_count_4 = 0; for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) if (OrderMagicNumber() == a_magic_0) l_count_4++; } return (l_count_4); } int orderclosebuy(int a_ticket_0) { double l_bid_24; string l_symbol_4 = Symbol(); double l_digits_12 = MarketInfo(l_symbol_4, MODE_DIGITS); for (int l_ord_total_20 = OrdersTotal(); l_ord_total_20 >= 0; l_ord_total_20--) { OrderSelect(l_ord_total_20, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == l_symbol_4 && OrderMagicNumber() == g_magic_432) { a_ticket_0 = OrderTicket(); OrderSelect(a_ticket_0, SELECT_BY_TICKET, MODE_TRADES); g_ord_lots_464 = OrderLots(); l_bid_24 = MarketInfo(l_symbol_4, MODE_BID); RefreshRates(); OrderClose(a_ticket_0, g_ord_lots_464, NormalizeDouble(l_bid_24, l_digits_12), 3, Fuchsia); } } g_ord_lots_464 = LotsBuy; return (0); } int orderclosesell(int a_ticket_0) { double l_ask_24; string l_symbol_4 = Symbol(); double l_digits_12 = MarketInfo(l_symbol_4, MODE_DIGITS); for (int l_ord_total_20 = OrdersTotal(); l_ord_total_20 >= 0; l_ord_total_20--) { OrderSelect(l_ord_total_20, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == l_symbol_4 && OrderMagicNumber() == g_magic_440) { a_ticket_0 = OrderTicket(); OrderSelect(a_ticket_0, SELECT_BY_TICKET, MODE_TRADES); g_ord_lots_472 = OrderLots(); l_ask_24 = MarketInfo(l_symbol_4, MODE_ASK); RefreshRates(); OrderClose(a_ticket_0, g_ord_lots_472, NormalizeDouble(l_ask_24, l_digits_12), 3, Lime); } } g_ord_lots_472 = LotsSell; return (0); } int start() { double ld_0; double ld_8; string l_symbol_16; double l_spread_24; double l_digits_32; double l_minlot_40; double l_ima_48; double l_istochastic_56; double l_istochastic_64; string ls_72; string ls_80; string ls_88; string ls_96; string ls_104; string ls_112; string ls_120; string ls_128; string ls_136; string ls_144; string ls_152; string ls_160; string ls_168; string ls_176; double ld_184; double ld_192; double l_bid_200; double l_ask_208; if (AccountNumber() == gi_692) { if (Month() < 8) { if (RiskMM) { if (Risk < 0.1 || Risk > 100.0) { Comment("Invalid Risk Value."); return (0); } LotsBuy = MathFloor(100.0 * (AccountFreeMargin() * AccountLeverage() * Risk * Point) / (Ask * MarketInfo(Symbol(), MODE_LOTSIZE) * MarketInfo(Symbol(), MODE_MINLOT))) * MarketInfo(Symbol(), MODE_MINLOT); LotsSell = MathFloor(100.0 * (AccountFreeMargin() * AccountLeverage() * Risk * Point) / (Ask * MarketInfo(Symbol(), MODE_LOTSIZE) * MarketInfo(Symbol(), MODE_MINLOT))) * MarketInfo(Symbol(), MODE_MINLOT); } if (RiskMM == FALSE) { } if (gd_672 != 0.0 && MinProfit > 0.0) { if (gd_672 <= AccountBalance() && AccountBalance() <= gd_672 + MinProfit) Multiplier = 1; else { if (AccountBalance() < gd_672) { } } } gd_672 = AccountBalance(); ld_0 = 0; ld_8 = 0; l_symbol_16 = OrderSymbol(); l_spread_24 = MarketInfo(l_symbol_16, MODE_SPREAD); l_digits_32 = MarketInfo(l_symbol_16, MODE_DIGITS); l_minlot_40 = MarketInfo(l_symbol_16, MODE_MINLOT); l_ima_48 = iMA(Symbol(), 0, MaPeriod, 0, MaMode, MaPrice, 1); l_istochastic_56 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_LWMA, 1, MODE_MAIN, 1); l_istochastic_64 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_LWMA, 1, MODE_SIGNAL, 1); ls_72 = "false"; ls_80 = "false"; if (l_istochastic_56 > l_istochastic_64) ls_72 = "true"; if (l_istochastic_56 < l_istochastic_64) ls_80 = "true"; ls_88 = "false"; ls_96 = "false"; if (ExtendedZone == FALSE && l_istochastic_64 < SimpleZoneBuy) ls_88 = "true"; if (ExtendedZone == FALSE && l_istochastic_64 > SimpleZoneSell) ls_96 = "true"; if (ExtendedZone == TRUE && l_istochastic_64 > StartZoneBuy && l_istochastic_64 < EndZoneBuy) ls_88 = "true"; if (ExtendedZone == TRUE && l_istochastic_64 > StartZoneSell && l_istochastic_64 < EndZoneSell) ls_96 = "true"; ls_104 = "false"; ls_112 = "false"; if (ExtendedZone == TRUE && l_istochastic_64 <= CloseLevelDnSell || l_istochastic_64 >= CloseLevelUpSell) ls_104 = "true"; if (ExtendedZone == TRUE && l_istochastic_64 >= CloseLevelUpBuy || l_istochastic_64 <= CloseLevelDnBuy) ls_112 = "true"; ls_120 = "false"; ls_128 = "false"; if (Ask > l_ima_48 || MaFilter == FALSE) ls_120 = "true"; if (Bid < l_ima_48 || MaFilter == FALSE) ls_128 = "true"; ls_136 = "false"; if (MaxSpread == MaxSpread || UseMaxSpread == FALSE) ls_136 = "true"; ls_144 = "false"; ls_152 = "false"; if (OrdersTotalMagicBuy(g_magic_432) < MaxBuyOrders || MaxOpenOrders == FALSE) ls_144 = "true"; if (OrdersTotalMagicSell(g_magic_440) < MaxSellOrders || MaxOpenOrders == FALSE) ls_152 = "true"; ls_160 = "false"; if (AccountEquity() < EquityTarget || UseEquityTarget == FALSE) ls_160 = "true"; ls_168 = "false"; if (AccountEquity() > EquityLoss || UseEquityLoss == FALSE) ls_168 = "true"; if (TimeFilter == TRUE && Hour() < StartHour || Hour() >= EndHour) return (0); ls_176 = "false"; if (CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) ls_176 = "true"; if (l_minlot_40 == 0.01) { gd_632 = 2; gd_592 = MarketInfo(l_symbol_16, MODE_MAXLOT); } if (l_minlot_40 == 0.1) { gd_632 = 1; gd_592 = AccountBalance() / 2.0 / 1000.0; } if (OrdersTotalMagicBuy(g_magic_432) > 0) { for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_432) { g_ticket_684 = OrderTicket(); OrderSelect(g_ticket_684, SELECT_BY_TICKET, MODE_TRADES); ld_184 += OrderLots(); g_ord_open_price_448 = OrderOpenPrice(); g_ord_lots_480 = OrderLots(); } } if (ld_184 + NormalizeDouble(g_ord_lots_480 * Multiplier, gd_632) < gd_592) { if (StepMode == 0) { if (Ask <= g_ord_open_price_448 - Step * Point && ls_120 == "true" && ls_136 == "true" && ls_144 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false" && ls_72 == "true" && ls_88 == "true") { g_ord_lots_464 = Multiplier * LotsBuy * OrdersTotalMagicBuy(g_magic_432); if (TakeProfit > 0.0) g_price_512 = Ask + TakeProfit * Point; else g_price_512 = 0; if (StopLoss > 0.0) g_price_528 = Ask - StopLoss * Point; else g_price_528 = 0; RefreshRates(); g_ticket_684 = OrderSend(Symbol(), OP_BUY, NormalizeDouble(g_ord_lots_464, gd_632), Ask, 3, g_price_528, g_price_512, "double Expert", g_magic_432, 0, Blue); } } if (StepMode == 1) { if (Ask <= g_ord_open_price_448 - (Step + OrdersTotalMagicBuy(g_magic_432) + OrdersTotalMagicBuy(g_magic_432) - 2.0) * Point && ls_120 == "true" && ls_136 == "true" && ls_144 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false" && ls_72 == "true" && ls_88 == "true") { g_ord_lots_464 = Multiplier * LotsBuy * OrdersTotalMagicBuy(g_magic_432); if (TakeProfit > 0.0) g_price_512 = Ask + TakeProfit * Point; else g_price_512 = 0; if (StopLoss > 0.0) g_price_528 = Ask - StopLoss * Point; else g_price_528 = 0; RefreshRates(); g_ticket_684 = OrderSend(Symbol(), OP_BUY, NormalizeDouble(g_ord_lots_464, gd_632), Ask, 3, g_price_528, g_price_512, "doubleExpert", g_magic_432, 0, Blue); } } } } if (OrdersTotalMagicSell(g_magic_440) > 0) { for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_440) { g_ticket_688 = OrderTicket(); OrderSelect(g_ticket_688, SELECT_BY_TICKET, MODE_TRADES); ld_192 += OrderLots(); g_ord_open_price_456 = OrderOpenPrice(); g_ord_lots_488 = OrderLots(); } } if (ld_192 + NormalizeDouble(g_ord_lots_488 * Multiplier, gd_632) < gd_592) { if (StepMode == 0) { if (Bid >= g_ord_open_price_456 + Step * Point && ls_128 == "true" && ls_136 == "true" && ls_152 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false" && ls_80 == "true" && ls_96 == "true") { g_ord_lots_472 = Multiplier * LotsSell * OrdersTotalMagicSell(g_magic_440); if (TakeProfit > 0.0) g_price_520 = Bid - TakeProfit * Point; else g_price_520 = 0; if (StopLoss > 0.0) g_price_536 = Bid + StopLoss * Point; else g_price_536 = 0; RefreshRates(); g_ticket_688 = OrderSend(Symbol(), OP_SELL, NormalizeDouble(g_ord_lots_472, gd_632), Bid, 3, g_price_536, g_price_520, "doubleExpert", g_magic_440, 0, Red); } } if (StepMode == 1) { if (Bid >= g_ord_open_price_456 + (Step + OrdersTotalMagicSell(g_magic_440) + OrdersTotalMagicSell(g_magic_440) - 2.0) * Point && ls_128 == "true" && ls_136 == "true" && ls_152 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false" && ls_80 == "true" && ls_96 == "true") { g_ord_lots_472 = Multiplier * LotsSell * OrdersTotalMagicSell(g_magic_440); if (TakeProfit > 0.0) g_price_520 = Bid - TakeProfit * Point; else g_price_520 = 0; if (StopLoss > 0.0) g_price_536 = Bid + StopLoss * Point; else g_price_536 = 0; RefreshRates(); g_ticket_688 = OrderSend(Symbol(), OP_SELL, NormalizeDouble(g_ord_lots_472, gd_632), Bid, 3, g_price_536, g_price_512, "doubleExpert", g_magic_440, 0, Red); } } } } if (OrdersTotalMagicBuy(g_magic_432) < 1) { if (TakeProfit > 0.0) g_price_512 = Ask + TakeProfit * Point; else g_price_512 = 0; if (StopLoss > 0.0) g_price_528 = Ask - StopLoss * Point; else g_price_528 = 0; if (ls_72 == "true" && ls_88 == "true" && ls_120 == "true" && ls_136 == "true" && ls_144 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false") g_ticket_684 = OrderSend(Symbol(), OP_BUY, LotsBuy, Ask, 3, g_price_528, g_price_512, "doubleExpert", g_magic_432, 0, Blue); } if (OrdersTotalMagicSell(g_magic_440) < 1) { if (TakeProfit > 0.0) g_price_520 = Bid - TakeProfit * Point; else g_price_520 = 0; if (StopLoss > 0.0) g_price_536 = Bid + StopLoss * Point; else g_price_536 = 0; if (ls_80 == "true" && ls_96 == "true" && ls_128 == "true" && ls_136 == "true" && ls_152 == "true" && ls_160 == "true" && ls_168 == "true" && ls_176 == "false") g_ticket_688 = OrderSend(Symbol(), OP_SELL, LotsSell, Bid, 3, g_price_536, g_price_520, "doubleExpert", g_magic_440, 0, Red); } for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_432) { g_ticket_684 = OrderTicket(); OrderSelect(g_ticket_684, SELECT_BY_TICKET, MODE_TRADES); ld_0 += OrderProfit(); g_ord_open_price_448 = OrderOpenPrice(); } } g_price_496 = OrdersTotalMagicBuy(g_magic_432) * AutomatedTPFactor * Point + g_ord_open_price_448; l_bid_200 = MarketInfo(Symbol(), MODE_BID); if (UseAutomatedTP == TRUE && ld_0 > 0.0) if (Bid >= g_price_496) orderclosebuy(g_ticket_684); for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_440) { g_ticket_688 = OrderTicket(); OrderSelect(g_ticket_688, SELECT_BY_TICKET, MODE_TRADES); ld_8 += OrderProfit(); g_ord_open_price_456 = OrderOpenPrice(); } } g_price_504 = g_ord_open_price_456 - OrdersTotalMagicSell(g_magic_440) * AutomatedTPFactor * Point; l_ask_208 = MarketInfo(Symbol(), MODE_ASK); if (UseAutomatedTP == TRUE && ld_8 > 0.0) if (Ask <= g_price_504) orderclosesell(g_ticket_688); g_free_magrin_600 = AccountFreeMargin(); gd_608 = AccountBalance(); for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_432) g_ticket_684 = OrderTicket(); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_440) g_ticket_688 = OrderTicket(); } if (ls_160 == "false" || ls_168 == "false" || ls_176 == "true") { orderclosesell(g_ticket_688); orderclosebuy(g_ticket_684); } if (ls_104 == "true") orderclosesell(g_ticket_688); if (ls_112 == "true") orderclosebuy(g_ticket_684); if (OrdersTotalMagicBuy(g_magic_432) == 0 || TakeProfit > 0.0) { ld_0 = 0; g_ticket_684 = 0; g_price_496 = 0; } if (OrdersTotalMagicSell(g_magic_440) == 0 || TakeProfit > 0.0) { ld_8 = 0; g_ticket_688 = 0; g_price_504 = 0; } for (int li_216 = 0; li_216 < 2; li_216 += 2) { ObjectDelete("rect" + li_216); ObjectCreate("rect" + li_216, OBJ_HLINE, 0, 0, g_price_504); ObjectSet("rect" + li_216, OBJPROP_COLOR, Red); ObjectSet("rect" + li_216, OBJPROP_WIDTH, 1); ObjectSet("rect" + li_216, OBJPROP_RAY, FALSE); } for (int li_220 = 0; li_220 < 2; li_220 += 2) { ObjectDelete("rect1" + li_220); ObjectCreate("rect1" + li_220, OBJ_HLINE, 0, 0, g_price_496); ObjectSet("rect1" + li_220, OBJPROP_COLOR, Blue); ObjectSet("rect1" + li_220, OBJPROP_WIDTH, 1); ObjectSet("rect1" + li_220, OBJPROP_RAY, FALSE); } if (OrdersTotalMagicBuy(g_magic_432) > 1) { for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_432) { g_ticket_684 = OrderTicket(); OrderSelect(g_ticket_684, SELECT_BY_TICKET, MODE_TRADES); g_ord_open_price_448 = OrderOpenPrice(); g_ord_stoploss_552 = OrderStopLoss(); g_ticket_684 = OrderTicket(); } } if (Bid - g_ord_open_price_448 > Point * TrailingStop) { if (g_ord_stoploss_552 < Bid - Point * (TrailingStop + TrailingStopStep - 1.0) || g_ord_stoploss_552 == 0.0) { if (TrailingStop > 0.0) { OrderModify(g_ticket_684, g_ord_open_price_448, NormalizeDouble(Bid - Point * TrailingStop, l_digits_32), 0, 0, Gold); return (0); } } } } if (OrdersTotalMagicSell(g_magic_440) > 1) { for (g_pos_544 = 0; g_pos_544 < OrdersTotal(); g_pos_544++) { OrderSelect(g_pos_544, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_440) { g_ticket_688 = OrderTicket(); OrderSelect(g_ticket_688, SELECT_BY_TICKET, MODE_TRADES); g_ord_open_price_456 = OrderOpenPrice(); g_ord_stoploss_560 = OrderStopLoss(); } } if (g_ord_open_price_456 - Ask > Point * TrailingStop) { if (g_ord_stoploss_560 > Ask + Point * (TrailingStop + TrailingStopStep - 1.0) || g_ord_stoploss_560 == 0.0) { if (TrailingStop > 0.0) { OrderModify(g_ticket_688, g_ord_open_price_456, NormalizeDouble(Ask + Point * TrailingStop, l_digits_32), 0, 0, Gold); return (0); } } } } Comment("FreeMargin = ", NormalizeDouble(g_free_magrin_600, 0), " Balance = ", NormalizeDouble(gd_608, 0), " maxLot = ", NormalizeDouble(gd_592, gd_632), "\n", "Totalbuy = ", OrdersTotalMagicBuy(g_magic_432), " Lot = ", ld_184, " Totalsell = ", OrdersTotalMagicSell(g_magic_440), " Lot = ", ld_192, "\n", "---------------------------------------------------------------", "\n", "Profitbuy = ", ld_0, "\n", "Profitsell = ", ld_8, "\n", "EA expire 08/2009"); if (g_ticket_684 < 0 || g_ticket_688 < 0) { if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) { gi_unused_680 = 1; Print("NOT ENOGUGHT MONEY!!"); } return (-1); } } } return (0); }