
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.