Is it possible to close all 100 open positions in 1 sec, in one go? - page 2

 

JBG

Whatever code you use, consider parallel processing, close all buys in one copy of MT, all sells in another copy of MT
This gives double the order channel 'bandwidth'

-BB-

 

Would also be interesting to extend the notion of parallel processing and try the "brawn before brains" approach.

Run about 10 instances of the platform and set the same decrementing loop running to indiscriminately close all orders.

CB

 
johnnybegoode:

Thanks!

I don't want to close one at each loop-run. I want to close all at once. The problem is the loop.

I think there is a need to re-code. I recently realize that MT4 could make more than 1 order at a time. Therefore it might be able to close all order at once. Closing one each loop will take time. Let say I have 1000 open orders, that will take minutes.

The problem is that there is a loop

int ctotal = OrdersTotal();
for(int j=ctotal-1;j>=0;j--)

and

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

can only close one at a time.

Is there a way to maybe get all the total order, but instead of creating a loop to OrderClose 1 by 1,

make mt4 do many

OrderClose statements?

e.x.

I got n number of total order, then MT4 do this

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );

..... n number etc?

???


There is no point to do that because you wont even loose a tenth of a millisecond for each loop run by doing so. If that is all you put in the loopthat is. The delay is in the sleepncommand and you wont get around that either way without errors. Maybe you are thinking a new tick is required for each loop run, if so that is not the case.

Good luck.

McKeen

 



  Thanks! Just gave it a try and it is still closing 1 by 1.  

 
You must refreshRates between each server call
 
I have been looking for same code long time ago, try many different way, still close one by one, I only open three order still takes minutes even hours to wait for next opotur, because the close condition may just last 1 second.
 
withdraw all money and let the margin call close all at once.
Reason: