//+------------------------------------------------------------------+ //| Copyright © 2013, Vladimir Khlystov | //| cmillion@narod.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2013, Vladimir Khlystov" #property link "cmillion@narod.ru" int slippage = 2;//delta //-------------------------------------------------------------------- int start() { double SL,TP; double Price = NormalizeDouble(WindowPriceOnDropped(),Digits); RefreshRates(); bool error=true; int Error,OT,Ticket,nn; double OOP,LotClose; for (int j = OrdersTotal()-1; j >= 0; j--) { if (OrderSelect(j, SELECT_BY_POS)) { if ((OrderSymbol() == Symbol())) { OT = OrderType(); Ticket = OrderTicket(); OOP = OrderOpenPrice(); if (OOP Price+slippage*Point) continue; if (OT==OP_BUY) { LotClose = OrderLots(); error=OrderClose(Ticket,LotClose,NormalizeDouble(Bid,Digits),slippage,Red); if (error) { OrderSend(Symbol(),OP_SELL,LotClose,NormalizeDouble(Bid,Digits),0,0,0,"",0,0,CLR_NONE); } } if (OT==OP_SELL) { LotClose = OrderLots(); error=OrderClose(Ticket,LotClose,NormalizeDouble(Ask,Digits),slippage,Blue); if (error) { OrderSend(Symbol(),OP_BUY,LotClose,NormalizeDouble(Ask,Digits),0,0,0,"",0,0,CLR_NONE); } } if (!error) { Error = GetLastError(); if (Error<2) continue; if (Error==129) { Sleep(5000); RefreshRates(); continue; } if (Error==146) { j++; if (IsTradeContextBusy()) Sleep(2000); continue; } } } } } return(0); } //--------------------------------------------------------------------