#property copyright "bibjQOOXDgt`t" #property link "" string gs_unused_76 = "---------------- Money Management"; double gd_84 = 0.0; double gd_92 = 4.5; extern double LotsBuy = 0.01; extern double LotsSell = 0.01; extern bool RiskMM = FALSE; extern double Risk = 0.0; string gs_unused_128 = "---------------- Order Management"; double g_pips_136 = 0.0; bool gi_144 = TRUE; double gd_148 = 13.0; double g_pips_156 = 0.0; double g_pips_164 = 0.0; double gd_172 = 1.0; bool gi_180 = FALSE; int gi_184 = 2; int gi_unused_188 = 3; bool gi_192 = TRUE; int gi_196 = 100; int gi_200 = 100; bool gi_204 = FALSE; int gi_208 = 15000; bool gi_212 = FALSE; int gi_216 = 8000; string gs_unused_220 = "---------------- Distance between orders"; double g_pips_228 = 22.0; int gi_236 = 0; string gs_unused_240 = "---------------- Stochastic Settings"; double g_period_248 = 20.0; double g_period_256 = 13.0; double g_slowing_264 = 13.0; double gd_272 = 25.0; double gd_280 = 0.0; bool gi_288 = TRUE; double gd_292 = 26.0; double gd_300 = 25.0; double gd_308 = 0.0; double gd_316 = 0.0; double gd_324 = 100.0; double gd_332 = 100.0; double gd_340 = 0.0; double gd_348 = 0.0; string gs_unused_356 = "---------------- MA Filter Settings"; bool gi_364 = TRUE; double g_period_368 = 11.0; double g_ma_method_376 = 3.0; double g_applied_price_384 = 0.0; string gs_unused_392 = "---------------- Time Filter Settings"; extern bool TimeFilter = FALSE; extern double StartHour = 0.0; extern double EndHour = 0.0; extern bool CloseFriday = FALSE; extern double CloseFridayHour = 0.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 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_184; double ld_192; 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 && gd_84 > 0.0) { if (gd_672 <= AccountBalance() && AccountBalance() <= gd_672 + gd_84) gd_92 = 1; else { if (AccountBalance() < gd_672) { } } } gd_672 = AccountBalance(); double ld_0 = 0; double ld_8 = 0; string l_symbol_16 = OrderSymbol(); double l_spread_24 = MarketInfo(l_symbol_16, MODE_SPREAD); double l_digits_32 = MarketInfo(l_symbol_16, MODE_DIGITS); double l_minlot_40 = MarketInfo(l_symbol_16, MODE_MINLOT); double l_ima_48 = iMA(Symbol(), 0, g_period_368, 0, g_ma_method_376, g_applied_price_384, 1); double l_istochastic_56 = iStochastic(NULL, 0, g_period_248, g_period_256, g_slowing_264, MODE_LWMA, 1, MODE_MAIN, 1); double l_istochastic_64 = iStochastic(NULL, 0, g_period_248, g_period_256, g_slowing_264, MODE_LWMA, 1, MODE_SIGNAL, 1); string ls_72 = "false"; string ls_80 = "false"; if (l_istochastic_56 > l_istochastic_64) ls_72 = "true"; if (l_istochastic_56 < l_istochastic_64) ls_80 = "true"; string ls_88 = "false"; string ls_96 = "false"; if (gi_288 == FALSE && l_istochastic_64 < gd_272) ls_88 = "true"; if (gi_288 == FALSE && l_istochastic_64 > gd_280) ls_96 = "true"; if (gi_288 == TRUE && l_istochastic_64 > gd_308 && l_istochastic_64 < gd_300) ls_88 = "true"; if (gi_288 == TRUE && l_istochastic_64 > gd_340 && l_istochastic_64 < gd_332) ls_96 = "true"; string ls_104 = "false"; string ls_112 = "false"; if (gi_288 == TRUE && l_istochastic_64 <= gd_348 || l_istochastic_64 >= gd_324) ls_104 = "true"; if (gi_288 == TRUE && l_istochastic_64 >= gd_292 || l_istochastic_64 <= gd_316) ls_112 = "true"; string ls_120 = "false"; string ls_128 = "false"; if (Ask > l_ima_48 || gi_364 == FALSE) ls_120 = "true"; if (Bid < l_ima_48 || gi_364 == FALSE) ls_128 = "true"; string ls_136 = "false"; if (gi_184 == gi_184 || gi_180 == FALSE) ls_136 = "true"; string ls_144 = "false"; string ls_152 = "false"; if (OrdersTotalMagicBuy(g_magic_432) < gi_196 || gi_192 == FALSE) ls_144 = "true"; if (OrdersTotalMagicSell(g_magic_440) < gi_200 || gi_192 == FALSE) ls_152 = "true"; string ls_160 = "false"; if (AccountEquity() < gi_208 || gi_204 == FALSE) ls_160 = "true"; string ls_168 = "false"; if (AccountEquity() > gi_216 || gi_212 == FALSE) ls_168 = "true"; if (TimeFilter == TRUE && Hour() < StartHour || Hour() >= EndHour) return (0); string 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 * gd_92, gd_632) < gd_592) { if (gi_236 == 0) { if (Ask <= g_ord_open_price_448 - g_pips_228 * 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 = gd_92 * LotsBuy * OrdersTotalMagicBuy(g_magic_432); if (g_pips_136 > 0.0) g_price_512 = Ask + g_pips_136 * Point; else g_price_512 = 0; if (g_pips_156 > 0.0) g_price_528 = Ask - g_pips_156 * 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, "MartingailExpert", g_magic_432, 0, Blue); } } if (gi_236 == 1) { if (Ask <= g_ord_open_price_448 - (g_pips_228 + 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 = gd_92 * LotsBuy * OrdersTotalMagicBuy(g_magic_432); if (g_pips_136 > 0.0) g_price_512 = Ask + g_pips_136 * Point; else g_price_512 = 0; if (g_pips_156 > 0.0) g_price_528 = Ask - g_pips_156 * 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, "MartingailExpert", 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 * gd_92, gd_632) < gd_592) { if (gi_236 == 0) { if (Bid >= g_ord_open_price_456 + g_pips_228 * 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 = gd_92 * LotsSell * OrdersTotalMagicSell(g_magic_440); if (g_pips_136 > 0.0) g_price_520 = Bid - g_pips_136 * Point; else g_price_520 = 0; if (g_pips_156 > 0.0) g_price_536 = Bid + g_pips_156 * 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, "MartingailExpert", g_magic_440, 0, Red); } } if (gi_236 == 1) { if (Bid >= g_ord_open_price_456 + (g_pips_228 + 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 = gd_92 * LotsSell * OrdersTotalMagicSell(g_magic_440); if (g_pips_136 > 0.0) g_price_520 = Bid - g_pips_136 * Point; else g_price_520 = 0; if (g_pips_156 > 0.0) g_price_536 = Bid + g_pips_156 * 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, "MartingailExpert", g_magic_440, 0, Red); } } } } if (OrdersTotalMagicBuy(g_magic_432) < 1) { if (g_pips_136 > 0.0) g_price_512 = Ask + g_pips_136 * Point; else g_price_512 = 0; if (g_pips_156 > 0.0) g_price_528 = Ask - g_pips_156 * 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, "MartingailExpert", g_magic_432, 0, Blue); } if (OrdersTotalMagicSell(g_magic_440) < 1) { if (g_pips_136 > 0.0) g_price_520 = Bid - g_pips_136 * Point; else g_price_520 = 0; if (g_pips_156 > 0.0) g_price_536 = Bid + g_pips_156 * 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, "MartingailExpert", 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) * gd_148 * Point + g_ord_open_price_448; double l_bid_200 = MarketInfo(Symbol(), MODE_BID); if (gi_144 == 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) * gd_148 * Point; double l_ask_208 = MarketInfo(Symbol(), MODE_ASK); if (gi_144 == 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 || g_pips_136 > 0.0) { ld_0 = 0; g_ticket_684 = 0; g_price_496 = 0; } if (OrdersTotalMagicSell(g_magic_440) == 0 || g_pips_136 > 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 * g_pips_164) { if (g_ord_stoploss_552 < Bid - Point * (g_pips_164 + gd_172 - 1.0) || g_ord_stoploss_552 == 0.0) { if (g_pips_164 > 0.0) { OrderModify(g_ticket_684, g_ord_open_price_448, NormalizeDouble(Bid - Point * g_pips_164, 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 * g_pips_164) { if (g_ord_stoploss_560 > Ask + Point * (g_pips_164 + gd_172 - 1.0) || g_ord_stoploss_560 == 0.0) { if (g_pips_164 > 0.0) { OrderModify(g_ticket_688, g_ord_open_price_456, NormalizeDouble(Ask + Point * g_pips_164, 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); 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); }