Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 493

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
Could you please advise whether the function of closing all orders opened by the EA by the symbol is implemented correctly?
The architecture itself is correct. The errors are in the lack of checks and the use of some functions:
The architecture itself is correct. The errors are in the lack of checks and the use of some functions:
Thank you, the main problem was probably just using the same price
From OrderSelect help " When orders are sequentially selected using SELECT_BY_POS parameter, the information is given in the order in which it came from the trade server. No sorting of the order list obtained is guaranteed".
If we think that this phrase was inserted in the help for nothing, we are OK. If we think that it was there for a reason, we should not change this list during the loop's run through the list of orders. How the orders will be ordered after the deletion of one of them on the server and the arrival of a new, current list with a smaller OrdersTotal, is unknown. It is more reliable, without deleting, to run through the same unchanged copy of the list and collect (in an array) all of the ticket numbers of the trades to be deleted. Then forget about that list and delete the trades, selecting them by ticket.
One would like to believe, of course, that the orderliness in the modifiable list is preserved, if only for this case of removing several orders from the end of an unordered list, but the developers are against it... Now it works, and if new build comes out - "we warned".
From OrderSelect help " When orders are sequentially selected using SELECT_BY_POS parameter, the information is given in the order in which it came from the trade server. No sorting of the order list obtained is guaranteed".
If we think that this phrase was inserted in the help for nothing, we are OK. If we think that it was there for a reason, we should not change this list during the loop's run through the list of orders. How the orders will be ordered after the deletion of one of them on the server and the arrival of a new, current list with a smaller OrdersTotal, is unknown. It is more reliable, without deleting, to run through the same unchanged copy of the list and collect (in an array) all of the ticket numbers of the trades to be deleted. Then forget about that list and delete the trades, selecting them by ticket.
One would like to believe, of course, that the orderliness in the modifiable list is preserved, if only for this case of removing several orders from the end of an unordered list, but the developers are against it... Now it works, and if new build comes out - "we warned".
Such "America" has been open for about three hundred years :)
This kind of "America" has been open for like three hundred years :)
I don't think the people asking questions here on behalf of newcomers have already discovered it themselves. That's why I'm writing it. Not for the moderators, but for the questioners. Look at the name of the thread.
P.S. I looked up where this interest came from. Turns out it's from the https://www.mql5.com/ru/forum/215783/page8 branch "Organising the Order Cycle". As it turns out, in October 2017, those three hundred years aren't over yet, there's still novelty.
I don't think the people asking questions here on behalf of newcomers have already discovered it themselves. That's why I'm writing it. Not for the moderators, but for the questioners. Look at the name of the thread.
P.S. I looked where this interest comes from. Turns out it's from the https://www.mql5.com/ru/forum/215783/page8 branch "Organising the order cycle". As it turns out, in October 2017 those three hundred years are not over yet, there is still novelty.
Wrong again :) Three hundred years started back at mql4.com - there was a time when it was actively discussed there. And there were even those moments that are described by you in "Now it works, and a new build will come out - "we warned". Only without warnings, and so several times - it depends, it doesn't depend on sorting...
And, yes, there is a special thread for such answers:
From OrderSelect help " When orders are sequentially selected using SELECT_BY_POS parameter, the information is given in the order in which it came from the trade server. No sorting of the order list obtained is guaranteed".
If we think that this phrase was inserted in the help for nothing, we are OK. If we think that it was there for a reason, we should not change this list during the loop's run through the list of orders. How the orders will be ordered after the deletion of one of them on the server and the arrival of a new, current list with a smaller OrdersTotal, is unknown. It is more reliable, without deleting, to run through the same unchanged copy of the list and collect (in an array) all of the ticket numbers of the trades to be deleted. Then forget about that list and delete the trades, selecting them by ticket.
I would like, of course, to believe that the ordering in the modifiable list is preserved at least for this case of deleting several orders from the end of an unordered list, but the developers are against it... Now it works, and if a new build comes out, "we warned you".
As a good idea (considering that there can be several Expert Advisors + trader working on the account in parallel), you can't perform trades in a loop at all. The necessary order is received, the operation is executed, the entire OnTick() is executed again (not necessarily with arrival of a new tick). And so on, until all necessary operations are executed.
Thus, forming an array to delete orders is equivalent to deleting orders in the loop.
There is a "Stop" button, how do I change its text to "Start" once pressed?
See my expert example
Look at my Expert Advisor example
Thank you, just what I needed.
Might be helpful to know, there is an error in missing positions--- ToFile EURUSD,H1: zero divide in 'ToFile.mq4' (62,39)
The text does not change in the tester, there is no such option?