datetime temp=0;
int start()
{
if(temp==0)
{
temp=TimeCurrent();
}
if(TimeCurrent()-temp > 1800 )
{
close();
temp=0;
}
return(0);
}
void close()
{
while(OrdersTotal() > 0)
{
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
int type = OrderType();
bool result = false;
switch(type)
{
case OP_BUY : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Pink);
break;
case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Pink);
break;
}
}
}
return(0);
}