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'
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.
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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
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
https://www.mql5.com/en/forum/104677
Thanks! Just gave it a try and it is still closing 1 by 1.