Please edit your post to show the code in code style.
When deleting or closing orders you always need to loop back to front:
//for(int i=0;i<=OrdersTotal();i++) for(int i=OrdersTotal()-1;i>=0;i--)
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor - You don't open any pending orders, therefor you can't delete them.
- 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:
- For non-FIFO
(non-US brokers), (or the EA only opens one order per symbol,) you can
simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
Loops and Closing or Deleting Orders - MQL4 programming forum
For In First Out (FIFO rules-US brokers,) and you (potentially) process multiple orders per symbol, you must find the earliest order, close it, and on a successful operation, reprocess all remaining positions.
CloseOrders by FIFO Rules - Strategy Tester - MQL4 programming forum - Page 2 #16
MetaTrader 5 platform beta build 2155: #1 № 11 ACCOUNT_FIFO_CLOSE - and check OrderSelect in case earlier positions were deleted.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use, on the next order / server call, the Predefined Variables (Bid/Ask) or (be direction independent and use) OrderClosePrice().
-
Using OrdersTotal/OrdersHistoryTotal
(MT4) or
PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect/Position select
loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
- For non-FIFO
(non-US brokers), (or the EA only opens one order per symbol,) you can
simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
lippmaje:
I have tried it ,.. but unfortunately it does not work
Please edit your post to show the code in code style.
When deleting or closing orders you always need to loop back to front:
Please show the current status of your work and explain what is not working.
lippmaje:
Please edit your post to show the code in code style.
When deleting or closing orders you always need to loop back to front:
for(int i=0;i<OrdersTotal();i++)
even this works
Jefferson Metha:
for(int i=0;i<OrdersTotal();i++)
even this works
Always count down when closing/deleting orders
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
Hii Guys
This is my first ea,..
It should delete any bending orders after hitting the target,.. i surrender ... i do not know why it does not work.
any help guys