anuj71:
Can you create a (long) array of OrderOpenTime()s and OrderTicket()s ,sort the array then close all but the last/first two elements of the array?
Hello,
I want to close all opened or which open trade automatically except 2 most recently opened trade.
My code
Problem : it closing all the trade except the most recent one. But i want Most 2 recent trade should not close.
Just skip the newest two.
for(int i = OrdersTotal() - 1 - BlindClose; i >= 0; --i) if(OrderSelect(i, SELECT_BY_POS)) { if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, clrNONE)) Print(__FUNCTION__ + " => Failed to Close Order #", OrderTicket(), " Error: ", GetLastError()); }

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
Hello,
I want to close all opened or which open trade automatically except 2 most recently opened trade.
My code
Problem : it closing all the trade except the most recent one. But i want Most 2 recent trade should not close.