close all open orders

 
Hello
I have a problem. I want to close all open orders at a time but takes longer than 5 minutes to close them. Usually more than 50 orders simultaneously.
This is the code I'm using to close:
OrdersTotal iOrdersTotal1 = int ();
for (int i1 = iOrdersTotal1-1, i1> = 0, i1 -)
{
OrderSelect (i1, SELECT_BY_POS);
OrderType iOrderType1 = int ();
switch (iOrderType1)
{
OP_BUY case:
{
RefreshRates (); OrderClose (OrderTicket (), OrderLots (), MarketInfo (OrderSymbol (),MODE_BID), 3, CLR_NONE);
}
OP_SELL case:
{
RefreshRates (); OrderClose (OrderTicket (), OrderLots (), MarketInfo (OrderSymbol (),MODE_ASK), 3, CLR_NONE);
}
}
}

The question is:

Is there any way to close all orders at once but take so long?

Thank you.
 

Please use this to post code . . . it makes it easier to read.

If you are using MarketInfo(Symbol, MODE_BID) you are not using a PredefinedVariable so you don't need to refresh the predefined variable that you aren't using . . .

What is int() ?

 
RaptorUK:

Please use this to post code . . . it makes it easier to read.

If you are using MarketInfo(Symbol, MODE_BID) you are not using a PredefinedVariable so you don't need to refresh the predefined variable that you aren't using . . .

What is int() ?

 
vulcano:


 
vulcano:



Then I have to remove the refrehsrates?
That will make closing faster?
 
vulcano:

Then I have to remove the refrehsrates?
That will make closing faster?
It will make it faster . . . . but maybe not by much.
 
vulcano:
I have a problem. I want to close all open orders at a time but takes longer than 5 minutes to close them. Usually more than 50 orders simultaneously.
That is a function of your broker's server. Ask them why it takes them an average of 6 seconds to close an order.