coloque-os dentro do código inserido start() close_all(); close_longs(); close_shorts(); close_all_in_profit(); coloque-os bem no final Código inserido void close_all() { int totalorders = OrdersTotal(); for(int i=totalorders-1;igt;=0;i--) { OrderSelect(i, SELECT_BY_POS); if ( OrderSymbol()==Symbol()) { if ( OrderType() == OP_SELL ) { OrderClose( OrderTicket(), OrderLots(), Ask, 0, Red ); } if ( OrderType() == OP_BUY ) { OrderClose( OrderTicket(), OrderLots(), Bid, 0, Blue ); } } } } Código inserido void close_longs() { int totalorders = OrdersTotal(); for(int i=totalorders-1;igt;=0;i--) { OrderSelect(i, SELECT_BY_POS); if ( OrderSymbol()==Symbol()) { if ( OrderType() == OP_BUY ) { OrderClose( OrderTicket(), OrderLots(), Bid, 0, Blue ); } } } } Código inserido void close_shorts() { int totalorders = OrdersTotal(); for(int i=totalorders-1;igt;=0;i--) { OrderSelect(i, SELECT_BY_POS); if ( OrderSymbol()==Symbol()) { if ( OrderType() == OP_SELL ) { OrderClose( OrderTicket(), OrderLots(), Ask, 0, Red ); } } } } Código inserido void close_all_in_profit() { int totalorders = OrdersTotal(); for(int i=totalorders-1;igt;=0;i--) { OrderSelect(i, SELECT_BY_POS); if ( OrderSymbol()==Symbol()) { if ( OrderType() == OP_SELL OrderProfit() gt; 0 ) { OrderClose( OrderTicket(), OrderLots(), Ask, 0, Red ); } if ( OrderType() == OP_BUY OrderProfit() gt; 0 ) { OrderClose( OrderTicket(), OrderLots(), Bid, 0, Blue ); } } } }