#property copyright "rodrigos.pt@hotmail.com" #property link "rodrigos.pt@hotmail.com" extern double Lots = 0.01; extern int TakeProfit = 30; extern int StopLoss = 300; int g_slippage_92 = 3; int gi_96 = 2; extern int StartHour = 0; extern int EndHour = 24; int gi_unused_108 = 951868800; int gi_unused_112 = -1; string gs_unused_116 = "DEMO is expired"; int gi_124 = 68236; int init() { if (AccountNumber() != gi_124) { Alert("Esse EA está programado para a conta 68236"); return (-1); } return (1); } int start() { double l_price_48; double l_price_56; double l_price_64; double l_lots_72; if (AccountNumber() != gi_124) return (-1); int l_ticket_0 = 0; int l_ticket_4 = 0; int l_ticket_8 = 0; int l_ticket_12 = 0; double l_ord_lots_16 = 0; double l_ord_lots_24 = 0; double l_ord_open_price_32 = 0; double l_ord_open_price_40 = 0; double l_ord_takeprofit_80 = 0; double l_ord_takeprofit_88 = 0; for (int l_pos_96 = 0; l_pos_96 < OrdersTotal(); l_pos_96++) { OrderSelect(l_pos_96, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol()) { if (OrderType() == OP_BUY && l_ticket_0 < OrderTicket()) { l_ord_lots_16 = OrderLots(); l_ord_open_price_32 = OrderOpenPrice(); l_ticket_0 = OrderTicket(); l_ord_takeprofit_88 = OrderTakeProfit(); } if (OrderType() == OP_SELL && l_ticket_4 < OrderTicket()) { l_ord_lots_24 = OrderLots(); l_ord_open_price_40 = OrderOpenPrice(); l_ticket_4 = OrderTicket(); l_ord_takeprofit_80 = OrderTakeProfit(); } if (OrderType() == OP_BUYLIMIT) l_ticket_8 = OrderTicket(); if (OrderType() == OP_SELLLIMIT) l_ticket_12 = OrderTicket(); } } if (l_ticket_0 == 0) { if (l_ticket_8 != 0) OrderDelete(l_ticket_8); l_price_56 = Ask - StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = Ask + TakeProfit * Point; if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) { OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_92, l_price_56, l_price_64, 0, 0, 0, CLR_NONE); if (l_ord_lots_24 != 0.0) return (0); } } if (l_ticket_4 == 0) { if (l_ticket_12 != 0) OrderDelete(l_ticket_12); l_price_56 = Bid + StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = Bid - TakeProfit * Point; if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) { OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_92, l_price_56, l_price_64, 0, 0, 0, CLR_NONE); return (0); } } if (l_ticket_0 != 0 && l_ticket_8 == 0) { l_price_48 = l_ord_open_price_32 - TakeProfit * Point; l_price_56 = l_price_48 - StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = l_ord_open_price_32; l_lots_72 = NormalizeDouble(2.0 * l_ord_lots_16, gi_96); OrderSend(Symbol(), OP_BUYLIMIT, l_lots_72, l_price_48, g_slippage_92, l_price_56, l_price_64, 0, 0, 0, CLR_NONE); for (l_pos_96 = 0; l_pos_96 < OrdersTotal(); l_pos_96++) { OrderSelect(l_pos_96, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && l_ticket_0 != OrderTicket()) { l_price_56 = l_ord_open_price_32 - StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = l_ord_open_price_32 + TakeProfit * Point; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_56, l_price_64, 0, CLR_NONE); } } return (0); } if (l_ticket_4 != 0 && l_ticket_12 == 0) { l_price_48 = l_ord_open_price_40 + TakeProfit * Point; l_price_56 = l_price_48 + StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = l_ord_open_price_40; l_lots_72 = NormalizeDouble(2.0 * l_ord_lots_24, gi_96); OrderSend(Symbol(), OP_SELLLIMIT, l_lots_72, l_price_48, g_slippage_92, l_price_56, l_price_64, 0, 0, 0, CLR_NONE); for (l_pos_96 = 0; l_pos_96 < OrdersTotal(); l_pos_96++) { OrderSelect(l_pos_96, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && l_ticket_4 != OrderTicket()) { l_price_56 = l_ord_open_price_40 + StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; l_price_64 = l_ord_open_price_40 - TakeProfit * Point; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_56, l_price_64, 0, CLR_NONE); } } return (0); } for (l_pos_96 = 0; l_pos_96 < OrdersTotal(); l_pos_96++) { OrderSelect(l_pos_96, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && l_ticket_0 != OrderTicket() && l_ord_takeprofit_88 != OrderTakeProfit()) { l_price_56 = l_ord_open_price_32 - StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_56, l_ord_takeprofit_88, 0, CLR_NONE); } if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && l_ticket_4 != OrderTicket() && l_ord_takeprofit_80 != OrderTakeProfit()) { l_price_56 = l_ord_open_price_40 + StopLoss * Point; if (StopLoss <= 0) l_price_56 = 0; OrderModify(OrderTicket(), OrderOpenPrice(), l_price_56, l_ord_takeprofit_80, 0, CLR_NONE); } } return (0); }