for (x = OrdersTotal() - 1; x < MaxOrders; x++)
instead try:
for(i=OrdersTotal()-1; i>=0; i--){
ubzen:
instead try:
Thanks for your reply but I actually tried that already...............when that is the code the EA doesn't close ANY trades at all
J_Cutts:
Thanks for your reply but I actually tried that already...............when that is the code the EA doesn't close ANY trades at all
Thanks for your reply but I actually tried that already...............when that is the code the EA doesn't close ANY trades at all
If this
for(i=OrdersTotal()-1; i>=0; i--){
doesn't work
this
for (x = OrdersTotal() - 1; x < MaxOrders; x++)
isn't gonna work for sure never ever
J_Cutts:
Thanks for your reply but I actually tried that already...............when that is the code the EA doesn't close ANY trades at all
Well you're selecting by "SELECT_BY_POS" x, y, i or whatever you're using for position needs to become 0 for the lone order to be selected. I'll recommend you use line base Print( Statements ) and GetLastError(). Something else might be wrong.
Thanks for your reply but I actually tried that already...............when that is the code the EA doesn't close ANY trades at all
for (y = .. if (OrderSelect(y, .. Sells ++; : if (Order == SIGNAL_CLOSESELL && .. OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
You've completed the for loop, nothing is selected, so why do you suppose the OrderClose Fails there?
Always test return codes, so you find out WHY.
if (!OrderClose(...)) Alert("OrderClose failed: ", GetLastError());
WHRoeder:
You've completed the for loop, nothing is selected, so why do you suppose the OrderClose Fails there?
Always test return codes, so you find out WHY.
the problem isn't in closing orders because when there are multiple trades open, the EA closes trades just fine...........the problem I am having is that if there is only a SINGLE TRADE open in the terminal, it does not close that trade when it should and I can't figure out why.................
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
Hi all, I am having trouble with my EA closing single trade positions. If I have more than 1 trade open the EA works just fine and closes trades when a close signal is generated. However, if there is only 1 trade open, the EA does not close the trade no matter how many times the close signal is generated. Help will be greatly appreciated. Here is the related portion of the EA: