//--------------------------------------------------------------------- // Закрыть ордера по рынку с указанным тейкпрофитом. //--------------------------------------------------------------------- #property copyright "© RickD 2006-2007" #property link "www.e2e-fx.net" //--------------------------------------------------------------------- // Эксперт, закрывающий ордера по рынку с указанным тейкпрофитом. // TakeProfit можно ставить 1, 2, 3, ... // Возможны реквоты со стороны брокера. //--------------------------------------------------------------------- extern int TakeProfit = 2; extern int Slippage = 3; void CloseOrders() { if (TakeProfit == 0) return; int cnt = OrdersTotal(); for (int i=cnt-1; i >= 0; i--) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; //if (OrderSymbol() != Symbol()) continue; //if (OrderMagicNumber() != Magic) continue; int type = OrderType(); if (type == OP_BUY) { if (Bid > OrderOpenPrice() + TakeProfit*Point) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage); } if (type == OP_SELL) { if (Ask < OrderOpenPrice() - TakeProfit*Point) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage); } } }