#property copyright "Copyright rodrigos.pt@hotmail.com" #property link "rodrigos.pt@hotmail.com" extern double Lots = 0.1; extern int TakeProfit = 30; extern int StopLoss = 300; extern bool ConstantStop = TRUE; 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; int g_slippage_176 = 3; int gi_180 = 2; extern int StartHour = 0; extern int EndHour = 24; extern int Magic = 111; int gi_196 = D'01.01.2008 03:30'; int gi_200 = 1576108800; string gs_204 = "Versão Expirou data 12/12/2019"; int gi_212 = 68236; int init() { if (AccountNumber() != gi_212) { Alert("Esse EA está programado para a conta 68236"); return (-1); } return (1); } int start() { double l_price_60; double l_price_68; double l_price_76; double l_lots_84; double l_pips_148; double l_pips_156; if (AccountNumber() != gi_212) return (-1); int l_ticket_0 = 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; double l_ord_lots_28 = 0; double l_ord_lots_36 = 0; double l_ord_open_price_44 = 0; double l_ord_open_price_52 = 0; double l_ord_takeprofit_92 = 0; double l_ord_takeprofit_100 = 0; double l_ord_lots_108 = 0; double l_ord_lots_116 = 0; double l_ord_lots_124 = 0; double l_ord_lots_132 = 0; double ld_164 = 0; double ld_172 = 0; for (int l_pos_180 = 0; l_pos_180 < OrdersTotal(); l_pos_180++) { OrderSelect(l_pos_180, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { if (OrderType() == OP_BUY && l_ticket_0 < OrderTicket()) { l_ord_lots_28 = OrderLots(); l_ord_open_price_44 = OrderOpenPrice(); l_ticket_0 = OrderTicket(); l_ord_takeprofit_100 = OrderTakeProfit(); if (OrderLots() == Lots) ld_164 = OrderOpenPrice() - StopLoss * Point; } if (OrderType() == OP_SELL && l_ticket_4 < OrderTicket()) { l_ord_lots_36 = OrderLots(); l_ord_open_price_52 = OrderOpenPrice(); l_ticket_4 = OrderTicket(); l_ord_takeprofit_92 = OrderTakeProfit(); if (OrderLots() == Lots) ld_172 = OrderOpenPrice() + StopLoss * Point; } if (OrderType() == OP_BUYLIMIT) { l_ticket_8 = OrderTicket(); l_ord_lots_124 = OrderLots(); } if (OrderType() == OP_SELLLIMIT) { l_ticket_12 = OrderTicket(); l_ord_lots_132 = OrderLots(); } if (OrderType() == OP_BUYSTOP) { l_ticket_16 = OrderTicket(); l_ord_lots_108 = OrderLots(); } if (OrderType() == OP_SELLSTOP) { l_ticket_20 = OrderTicket(); l_ord_lots_116 = OrderLots(); } } } if (l_ticket_0 == 0) { if (l_ticket_8 != 0) OrderDelete(l_ticket_8); if (l_ticket_16 != 0) OrderDelete(l_ticket_16); l_price_68 = Ask - StopLoss * Point; if (StopLoss <= 0) l_price_68 = 0; l_price_76 = Ask + TakeProfit * Point; if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) { if (TimeCurrent() >= gi_196 && TimeCurrent() <= gi_200) OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_176, l_price_68, l_price_76, "Magic = " + Magic, Magic, 0, CLR_NONE); else Alert(gs_204); } } if (l_ticket_4 == 0) { if (l_ticket_12 != 0) OrderDelete(l_ticket_12); if (l_ticket_20 != 0) OrderDelete(l_ticket_20); l_price_68 = Bid + StopLoss * Point; if (StopLoss <= 0) l_price_68 = 0; l_price_76 = Bid - TakeProfit * Point; if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) { if (TimeCurrent() >= gi_196 && TimeCurrent() <= gi_200) OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_176, l_price_68, l_price_76, "Magic = " + Magic, Magic, 0, CLR_NONE); else Alert(gs_204); } } if (l_ticket_0 != 0 && l_ticket_8 == 0) { l_pips_156 = FinalStep(l_ord_lots_28); l_pips_148 = FinalTP(l_ord_lots_28); l_price_60 = l_ord_open_price_44 - l_pips_156 * Point; if (ConstantStop == FALSE) l_price_68 = l_price_60 - StopLoss * Point; else l_price_68 = ld_164; if (StopLoss <= 0) l_price_68 = 0; l_price_76 = l_price_60 + l_pips_148 * Point; l_lots_84 = NormalizeDouble(2.0 * l_ord_lots_28, gi_180); OrderSend(Symbol(), OP_BUYLIMIT, l_lots_84, l_price_60, g_slippage_176, l_price_68, l_price_76, "Magic = " + Magic, Magic, 0, CLR_NONE); } if (l_ticket_4 != 0 && l_ticket_12 == 0) { l_pips_156 = FinalStep(l_ord_lots_36); l_pips_148 = FinalTP(l_ord_lots_36); l_price_60 = l_ord_open_price_52 + l_pips_156 * Point; if (ConstantStop == FALSE) l_price_68 = l_price_60 + StopLoss * Point; else l_price_68 = ld_172; if (StopLoss <= 0) l_price_68 = 0; l_price_76 = l_price_60 - l_pips_148 * Point; l_lots_84 = NormalizeDouble(2.0 * l_ord_lots_36, gi_180); OrderSend(Symbol(), OP_SELLLIMIT, l_lots_84, l_price_60, g_slippage_176, l_price_68, l_price_76, "Magic = " + Magic, Magic, 0, CLR_NONE); } for (l_pos_180 = 0; l_pos_180 < OrdersTotal(); l_pos_180++) { OrderSelect(l_pos_180, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && l_ticket_0 != 0 && OrderMagicNumber() == Magic) { if (ConstantStop == FALSE) l_price_68 = l_ord_open_price_44 - StopLoss * Point; else l_price_68 = ld_164; if (StopLoss <= 0) l_price_68 = 0; if (l_ticket_0 != OrderTicket()) l_price_76 = l_ord_takeprofit_100; else l_price_76 = OrderTakeProfit(); if (l_price_76 != OrderTakeProfit() || l_price_68 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_68, l_price_76, 0, CLR_NONE); } if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && l_ticket_4 != 0 && OrderMagicNumber() == Magic) { if (ConstantStop == FALSE) l_price_68 = l_ord_open_price_52 + StopLoss * Point; else l_price_68 = ld_172; if (StopLoss <= 0) l_price_68 = 0; if (l_ticket_4 != OrderTicket()) l_price_76 = l_ord_takeprofit_92; else l_price_76 = OrderTakeProfit(); if (l_price_76 != OrderTakeProfit() || l_price_68 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_68, l_price_76, 0, CLR_NONE); } } return (0); } int FinalStep(double ad_0) { ad_0 = NormalizeDouble(ad_0 / Lots, 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) { ad_0 = NormalizeDouble(ad_0 / Lots, 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); }