In the presence of multiple orders (one EA
multiple charts, multiple EAs, manual
trading,) while you are waiting for the current operation (closing, deleting,
modifying) to complete, any number of other operations on other orders could
have concurrently happened and changed the position indexing:
and if you (potentially) process multiple orders, must call
RefreshRates() after server calls if you want to use the Predefined Variables(Bid/Ask) or OrderClosePrice() instead, on the next order/server
call.
Counting up Or counting down has nothing to do with your problem your problem comes from the fact that you do not consider ordertype before calling switch. So in the end EA tries to close pending order with rules for closing active orders and vice versa
Your final code should look like this
Lakshan Perera:
Yes that is true, I also just realized it, added to my code above.
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
Loops and Closing or Deleting Orders - MQL4 and MetaTrader 4 - MQL4 programming forum
For FIFO (US brokers,) and you (potentially) process multiple orders per symbol, you must count up and on a successful operation, reprocess all positions (set index to -1 before continuing.)
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
Counting up Or counting down has nothing to do with your problem your problem comes from the fact that you do not consider ordertype before calling switch. So in the end EA tries to close pending order with rules for closing active orders and vice versa
Your final code should look like this
Yes that is true, I also just realized it, added to my code above.
OMG...
It was a real mistake
thanks for all
yes, now no 4108 error again
OMG...
It was a real mistake
thanks for all
yes, now no 4108 error again
You're welcome