the code looks fine and may have logical error and that is difficult to find
Make it to your habit to count down openOrders!
int countOrders = OrdersTotal(); while (countOrders-->0) {..
For example if you close order 0 in the list of open orders order 1 became order 0 and countOrders would be one less and if you try to do something with the last order you'll fail.
Additionally mt4 does not guaranty any sort order like time-open, time-close, profit, type, ticket,... so you have to loop though all of them anyway!
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 have a (simple?) problem with my EA (code below).
What it should do is to positionate the stoploss depending on the current price. The orders are entered manually before. The code checkes permanently if there are any active trades. If yes, then the price of all acitve trades should be checked.
If only one trade is active, than everything is fine - the stoploss is set to the right points at the right time. But if another trade becomes active, he only checks the one which was opened at last. On this trade the positioning of the stoploss also acts normal. If the trade closes, one of the other active trades is permanently checked by the EA.
So the only problem I have is, that the EA doesn't checks more than one active trade at the same time till this trade is closed - no mather what the others are doing. The EA has the right count of active trades.
Has anyone an idea? I can't find an logical bug in my code...
Regards, MisterM