#property copyright "FXPROMaker Trading Solutions" #property link "http://www.fxpromaker.com" extern double Lots = 0.1; extern int TakeProfit = 30; extern int StopLoss = 0; extern bool ConstantStop = FALSE; extern int Step1 = 30; extern int TP1 = 30; extern int Step2 = 30; extern int TP2 = 30; extern int Step3 = 30; extern int TP3 = 30; extern int Step4 = 30; extern int TP4 = 30; extern int Step5 = 30; extern int TP5 = 30; extern int Step6 = 30; extern int TP6 = 30; extern int Step7 = 30; extern int TP7 = 30; extern int Step8 = 30; extern int TP8 = 30; extern int Step9 = 30; extern int TP9 = 30; extern int Step10 = 30; extern int TP10 = 30; extern int Slippage = 3; int gi_180 = 2; extern int StartHour = 0; extern int EndHour = 24; extern int Magic = 111; extern bool CloseAllNow = FALSE; extern bool UseMACD = TRUE; extern int BrokerMode = 1; extern bool MM_advisor = FALSE; extern int FridayCloseTime = 10; int gi_216 = D'01.01.2008 03:30'; int gi_220 = D'07.08.2009 04:30'; string gs_224 = "FXPROMAKER is expired. Visit www.fxpromaker.com"; int init() { if (!IsDemo()) { Comment("Invalid Account. Please contact EA Provider"); return (-1); } return (1); } int start() { int li_28; int li_32; int l_ticket_36; double l_price_72; double l_price_80; double l_price_88; double l_lots_96; double l_pips_160; double l_pips_168; double l_price_208; double l_price_216; double l_price_224; bool l_bool_320; if (!IsDemo()) return (-1); if (CloseAllNow == TRUE) { 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() || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 5, CLR_NONE); if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); } } return (0); } int l_ticket_4 = 0; int l_ticket_8 = 0; int l_ticket_12 = 0; int l_ticket_16 = 0; int l_ticket_20 = 0; int l_ticket_24 = 0; double ld_40 = 0; double ld_48 = 0; double l_ord_open_price_56 = 0; double l_ord_open_price_64 = 0; double l_ord_takeprofit_104 = 0; double l_ord_takeprofit_112 = 0; double l_ord_lots_120 = 0; double l_ord_lots_128 = 0; double l_ord_lots_136 = 0; double l_ord_lots_144 = 0; double ld_176 = 0; double ld_184 = 0; double l_ord_lots_192 = 0; double l_ord_lots_200 = 0; string ls_232 = ""; string ls_240 = ""; string ls_248 = ""; string ls_256 = ""; string ls_264 = ""; string ls_272 = ""; string ls_280 = ""; string ls_288 = ""; string ls_296 = ""; string ls_304 = ""; string ls_312 = ""; if (MM_advisor == TRUE) li_32 = 100; else li_32 = 1; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 2; if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) li_28 = 1; for (int l_pos_324 = 0; l_pos_324 < OrdersTotal(); l_pos_324++) { OrderSelect(l_pos_324, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY && OrderLots() > ld_40) { ld_40 = OrderLots(); l_ord_open_price_56 = OrderOpenPrice(); l_ticket_4 = OrderTicket(); l_ord_takeprofit_112 = OrderTakeProfit(); } if (OrderType() == OP_BUY) { if (OrderLots() < l_ord_lots_192 || l_ord_lots_192 == 0.0) { l_ord_lots_192 = OrderLots(); ld_176 = OrderOpenPrice() - StopLoss * Point; } } if (OrderType() == OP_SELL && OrderLots() > ld_48) { ld_48 = OrderLots(); l_ord_open_price_64 = OrderOpenPrice(); l_ticket_8 = OrderTicket(); l_ord_takeprofit_104 = OrderTakeProfit(); } if (OrderType() == OP_SELL) { if (OrderLots() < l_ord_lots_200 || l_ord_lots_200 == 0.0) { l_ord_lots_200 = OrderLots(); ld_184 = OrderOpenPrice() + StopLoss * Point; } } if (OrderType() == OP_BUYLIMIT) { l_ticket_12 = OrderTicket(); l_ord_lots_136 = OrderLots(); } if (OrderType() == OP_SELLLIMIT) { l_ticket_16 = OrderTicket(); l_ord_lots_144 = OrderLots(); } if (OrderType() == OP_BUYSTOP) { l_ticket_20 = OrderTicket(); l_ord_lots_120 = OrderLots(); } if (OrderType() == OP_SELLSTOP) { l_ticket_24 = OrderTicket(); l_ord_lots_128 = OrderLots(); } } } if (l_ticket_4 == 0 && l_ticket_12 != 0) OrderDelete(l_ticket_12); if (l_ticket_4 == 0 && l_ticket_12 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() <= gi_220) { l_price_80 = Ask - StopLoss * Point; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = Ask + TakeProfit * Point; if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_28 == 2 && l_ticket_8 == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots * li_32) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else { l_ticket_36 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "Magic = " + Magic, Magic, 0, CLR_NONE); if (l_ticket_36 > 0) { l_bool_320 = OrderModify(l_ticket_36, OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); if (l_bool_320 == FALSE) Print("Error modifying BUY order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_BUY, Lots) >= 0.0) ls_296 = "we recommend you to decrease your start lot or increase deposit"; else ls_248 = "BUY, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_240 = gs_224; } if (l_ticket_8 == 0 && l_ticket_16 != 0) OrderDelete(l_ticket_16); if (l_ticket_8 == 0 && l_ticket_16 == 0) { if (TimeCurrent() >= gi_216 && TimeCurrent() <= gi_220) { l_price_80 = Bid + StopLoss * Point; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = Bid - TakeProfit * Point; if ((StartHour < EndHour && TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) || (StartHour > EndHour && TimeHour(TimeCurrent()) >= StartHour || TimeHour(TimeCurrent()) < EndHour)) { if (DayOfWeek() != 5 || Hour() < FridayCloseTime) { if ((li_28 == 1 && l_ticket_4 == 0) || UseMACD == FALSE) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots * li_32) >= 0.0) { if (BrokerMode != 2 && BrokerMode != 3) OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else { l_ticket_36 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "Magic = " + Magic, Magic, 0, CLR_NONE); if (l_ticket_36 > 0) { l_bool_320 = OrderModify(l_ticket_36, OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); if (l_bool_320 == FALSE) Print("Error modifying SELL order : ", GetLastError()); } } } else { if (AccountFreeMarginCheck(Symbol(), OP_SELL, Lots) >= 0.0) ls_296 = "we recommend you to decrease your start lot or increase deposit"; else ls_256 = "SELL, " + DoubleToStr(Lots, 2) + " lots. "; } } } } } else ls_240 = gs_224; } if (l_ticket_4 != 0 && l_ticket_12 != 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, l_ord_lots_136) < 0.0) { ls_280 = "BUYLIMIT, " + DoubleToStr(l_ord_lots_136, 2) + " lots. "; OrderDelete(l_ticket_12); } } if (l_ticket_4 != 0 && l_ticket_12 == 0) { if (AccountFreeMarginCheck(Symbol(), OP_BUY, 2.0 * ld_40) >= 0.0) { l_pips_168 = FinalStep(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); l_pips_160 = FinalTP(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); l_price_72 = l_ord_open_price_56 - l_pips_168 * Point; if (ConstantStop == FALSE) l_price_80 = l_price_72 - StopLoss * Point; else l_price_80 = ld_176; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = l_price_72 + l_pips_160 * Point; l_lots_96 = NormalizeDouble(2.0 * ld_40, gi_180); l_ticket_12 = OrderSend(Symbol(), OP_BUYLIMIT, l_lots_96, l_price_72, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); } else ls_264 = "BUYLIMIT, " + DoubleToStr(2.0 * ld_40, 2) + " lots. "; } if (l_ticket_8 != 0 && l_ticket_16 != 0) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, l_ord_lots_144) < 0.0) { ls_288 = "SELLLIMIT, " + DoubleToStr(l_ord_lots_144, 2) + " lots. "; OrderDelete(l_ticket_16); } } if (l_ticket_8 != 0 && l_ticket_16 == 0) { if (AccountFreeMarginCheck(Symbol(), OP_SELL, 2.0 * ld_48) >= 0.0) { l_pips_168 = FinalStep(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); l_pips_160 = FinalTP(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); l_price_72 = l_ord_open_price_64 + l_pips_168 * Point; if (ConstantStop == FALSE) l_price_80 = l_price_72 + StopLoss * Point; else l_price_80 = ld_184; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = l_price_72 - l_pips_160 * Point; l_lots_96 = NormalizeDouble(2.0 * ld_48, gi_180); l_ticket_16 = OrderSend(Symbol(), OP_SELLLIMIT, l_lots_96, l_price_72, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); } else ls_272 = "SELLLIMIT, " + DoubleToStr(2.0 * ld_48, 2) + " lots. "; } if (l_ticket_20 != 0 && l_ord_lots_120 <= ld_40 || l_ord_lots_120 == l_ord_lots_136) OrderDelete(l_ticket_20); if (l_ord_lots_192 != 0.0) l_pips_168 = FinalStep(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); if (l_ticket_4 != 0 && l_ord_open_price_56 - Ask > l_pips_168 * Point && l_ticket_12 <= 0 || l_ticket_20 == 0) { l_price_72 = l_ord_open_price_56 - l_pips_168 * Point; l_price_224 = Ask; while (l_price_72 >= l_price_224) { ld_40 = 2.0 * ld_40; l_pips_168 = FinalStep(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); l_price_72 -= l_pips_168 * Point; if (l_price_72 < l_price_224) { if (l_ticket_12 <= 0) { l_ticket_12 = -2; l_pips_160 = FinalTP(NormalizeDouble(ld_40 / l_ord_lots_192, 0)); if (ConstantStop == FALSE) l_price_80 = l_price_72 - StopLoss * Point; else l_price_80 = ld_176; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = l_price_72 + l_pips_160 * Point; l_lots_96 = NormalizeDouble(2.0 * ld_40, gi_180); if (AccountFreeMarginCheck(Symbol(), OP_BUY, 2.0 * ld_40) >= 0.0) l_ticket_12 = OrderSend(Symbol(), OP_BUYLIMIT, l_lots_96, l_price_72, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else ls_304 = "BUYLIMIT, " + DoubleToStr(l_lots_96, 2) + " lots. "; } if (l_ticket_20 == 0 && ld_40 != l_ord_lots_136 && l_ticket_12 != -2) { l_price_208 = l_price_72 + l_pips_168 * Point; l_pips_160 = FinalTP(NormalizeDouble(ld_40 / 2.0 / l_ord_lots_192, 0)); l_price_88 = l_price_208 + l_pips_160 * Point; l_lots_96 = NormalizeDouble(ld_40, gi_180); if (ConstantStop == FALSE) l_price_80 = l_price_208 - StopLoss * Point; else l_price_80 = ld_176; if (StopLoss <= 0) l_price_80 = 0; l_ticket_36 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_96, l_price_208, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); } } } } if (l_ticket_24 != 0 && l_ord_lots_128 <= ld_48 || l_ord_lots_128 == l_ord_lots_144) OrderDelete(l_ticket_24); if (l_ord_lots_200 != 0.0) l_pips_168 = FinalStep(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); if (l_ticket_8 != 0 && Bid - l_ord_open_price_64 > l_pips_168 * Point && l_ticket_16 <= 0 || l_ticket_24 == 0) { l_price_72 = l_ord_open_price_64 + l_pips_168 * Point; l_price_224 = Bid; while (l_price_72 <= l_price_224) { ld_48 = 2.0 * ld_48; l_pips_168 = FinalStep(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); l_price_72 += l_pips_168 * Point; if (l_price_72 > l_price_224) { if (l_ticket_16 <= 0) { l_ticket_16 = -2; l_pips_160 = FinalTP(NormalizeDouble(ld_48 / l_ord_lots_200, 0)); if (ConstantStop == FALSE) l_price_80 = l_price_72 + StopLoss * Point; else l_price_80 = ld_184; if (StopLoss <= 0) l_price_80 = 0; l_price_88 = l_price_72 - l_pips_160 * Point; l_lots_96 = NormalizeDouble(2.0 * ld_48, gi_180); if (AccountFreeMarginCheck(Symbol(), OP_SELL, 2.0 * ld_48) >= 0.0) l_ticket_16 = OrderSend(Symbol(), OP_SELLLIMIT, l_lots_96, l_price_72, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); else ls_312 = "SELLLIMIT, " + DoubleToStr(l_lots_96, 2) + " lots. "; } if (l_ticket_24 == 0 && ld_48 != l_ord_lots_144 && l_ticket_16 != -2) { l_price_216 = l_price_72 - l_pips_168 * Point; l_pips_160 = FinalTP(NormalizeDouble(ld_48 / 2.0 / l_ord_lots_200, 0)); l_price_88 = l_price_216 - l_pips_160 * Point; l_lots_96 = NormalizeDouble(ld_48, gi_180); if (ConstantStop == FALSE) l_price_80 = l_price_216 + StopLoss * Point; else l_price_80 = ld_184; if (StopLoss <= 0) l_price_80 = 0; l_ticket_36 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_96, l_price_216, Slippage, l_price_80, l_price_88, "Magic = " + Magic, Magic, 0, CLR_NONE); } } } } for (l_pos_324 = 0; l_pos_324 < OrdersTotal(); l_pos_324++) { OrderSelect(l_pos_324, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderType() == OP_BUY && l_ticket_4 != 0 && OrderMagicNumber() == Magic) { if (ConstantStop == FALSE) l_price_80 = l_ord_open_price_56 - StopLoss * Point; else l_price_80 = ld_176; if (StopLoss <= 0) l_price_80 = 0; if (OrderLots() < ld_40) l_price_88 = l_ord_takeprofit_112; else l_price_88 = OrderTakeProfit(); if (l_price_88 != OrderTakeProfit() || l_price_80 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); } if (OrderSymbol() == Symbol() || BrokerMode == 3 && OrderType() == OP_SELL && l_ticket_8 != 0 && OrderMagicNumber() == Magic) { if (ConstantStop == FALSE) l_price_80 = l_ord_open_price_64 + StopLoss * Point; else l_price_80 = ld_184; if (StopLoss <= 0) l_price_80 = 0; if (OrderLots() < ld_48) l_price_88 = l_ord_takeprofit_104; else l_price_88 = OrderTakeProfit(); if (l_price_88 != OrderTakeProfit() || l_price_80 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_80, l_price_88, 0, CLR_NONE); } } if (ls_248 != "" || ls_256 != "" || ls_264 != "" || ls_272 != "" || ls_280 != "" || ls_288 != "" || ls_304 != "" || ls_312 != "") ls_232 = "Not enough margin for opening orders: "; Comment(ls_240, "\n", ls_232, ls_248, ls_256, ls_264, ls_272, ls_280, ls_288, ls_304, ls_312, "\n", ls_296); return (0); } int FinalStep(double ad_0) { switch (ad_0) { case 1.0: return (Step1); case 2.0: return (Step2); case 4.0: return (Step3); case 8.0: return (Step4); case 16.0: return (Step5); case 32.0: return (Step6); case 64.0: return (Step7); case 128.0: return (Step8); case 256.0: return (Step9); case 512.0: return (Step10); } return (Step10); } int FinalTP(double ad_0) { switch (ad_0) { case 1.0: return (TP1); case 2.0: return (TP2); case 4.0: return (TP3); case 8.0: return (TP4); case 16.0: return (TP5); case 32.0: return (TP6); case 64.0: return (TP7); case 128.0: return (TP8); case 256.0: return (TP9); case 512.0: return (TP10); } return (TP10); }