Don't count up when closing orders.
If Sleep() Refreshrates() to get up to date Bid and Ask
for(cnt=0;cnt<total;cnt++) change to for(cnt=total-1;cnt>=0;cnt--)
- You must RefreshRates after Sleep and between multiple server calls (OrderClose).
- In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading) you must count down when closing/deleting/modifying in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
- You don't have to test the OrderType, just use OrderClosePrice instead of Bid/Ask.
GumRai:
Thanks... works great now
Don't count up when closing orders.
If Sleep() Refreshrates() to get up to date Bid and Ask

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
My EA opens a series of orders. When collective profits hit a certain target, it does this routine.
However, it leaves one order still open. In the middle of the pack no less.
I put the slipage to an unearthly high number hoping that would help... didn't .
See anything wrong? Anything else I can do to fore the closing of all orders?