Is it enough to iterate trades backwards?
no
For some reason it does not close all trades at the same time.
there is no way to close multiple trades at the exact same time (you can try whit SL / TP)
Fifo requires closing oldest first. Your loop down is reverse ticket number (for non-pending orders is newest first.)
Counting up won't work Loops and Closing or Deleting Orders - MQL4 forum
Ticket number order won't work in general because pending orders open based on price, not ticket number.
Fifo also breaks mq4 model with stop loss/TP. If you move the oldest order SL up, all newer trades will move their SL down so they won't close before the older.
- Get ticket numbers ordered by open time GetSortedOrders()
- Use a broker that does the fifo accounting on the backside and don't worry about it.
Fifo requires closing oldest first. Your loop down is reverse ticket number (for non-pending orders is newest first.)
Counting up won't work Loops and Closing or Deleting Orders - MQL4 forum
Ticket number order won't work in general because pending orders open based on price, not ticket number.
Fifo also breaks mq4 model with stop loss/TP. If you move the oldest order SL up, all newer trades will move their SL down so they won't close before the older.
- Get ticket numbers ordered by open time GetSortedOrders()
- Use a broker that does the fifo accounting on the backside and don't worry about it.
Thanks a lot, like always :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good afternoon,
I hope you are fine. I would like to ask wether closing all trades with the following function is FIFO compliant, just to check.
Is it enough to iterate trades backwards? For some reason it does not close all trades at the same time.
Thanks in advance!