It's hard to see the issue with your code that closes orders if you don't show it . . .
If you are closing Orders you MUST count down, not up . . . Loops and Closing or Deleting Orders
Great thanks for you RaptorUK,
Your detailed explanation is very simple and i guess this is the good reason for my amazing tests.
I was wondering, how come that; the equity is reaching 12-20x times of the balance and sudden extreme losses later on.
If you are referring to the tester's graph. It could be due to the fact that you're testing a no-stop-loss system. You either ran out of money or the test stopped when one bad order was still losing.

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
I've a major problem with My EA as detailed below; please help and advice with partially written CODE as possible.
Introduction:
- My EA is instructed to start by certain neutral conditions, till only one of the GoLG (buy) or GoSH (sell) condition(s) is met.
- The last OrderType() should be stored in order to be used as a controller for the next order (I mean the last RUNNING position and not the last closed one in history).
- In case of, the LastOrderType() == OP_BUY/OP_SELL, My EA should be prepared for KeepLG/KeepSH if the GoLG/GoSH condition is met for the next order.
My Problem:How to instruct My EA to make sure that, CloseALL of the concurrent orders upon the reversal signal, and hence to avoid mixed positions?
I've tried the following code as a solution, But I found it results in OrderClose Error 138 (ERR_REQUOTE) although this loop should continue till killing all the positions at the market price.
I can see the OrderCloseBy() can help, but I'm not sure how to manage its parameters and get it loop incorporated to close the (n) Orders at all.
PLEASE ADVICE!