void CloseAll()
{
bool cl;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUY)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),Slip,White);
}
if(OrderType()==OP_SELL)
{
RefreshRates();
cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),Slip,White);
}
}
}
}
}
и изменил условия в OnTick:
if(CountTrades()>1 && CountTrades()<2 && t!=Time[0])
{
CloseAll();
t=Time[0];
}
if(CountTrades()<1 && t!=Time[0])
{
OpenPos();
t=Time[0];
}
все верно?
vit-fx