ลองเอาไปดูครับ
int start()
{ int total =OrdersTotal();
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
{ if( (OrderOpenPrice()-Ask >= Point*50) || (OrderOpenPrice()-Ask <= -(Point*50 )))
{
for(int i=0;i<total;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);
}
}
}
}
if(OrderType()==OP_SELL)
{ if( (OrderOpenPrice()-Bid >= Point*50) || (OrderOpenPrice()- Bid <= -(Point*50 )))
{
for( i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
type = OrderType();
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);
}
}
}
}
return(0);
}