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

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
The error is not in the code of searching for the penultimate, but most likely, in the output of information in the text.
We have never said anything about an error in the code. I will repeat once again, this code works when a new maximum order is opened and when this does not happen, the Expert Advisor considers that the penultimate order = the last one. That is all
The error is not in the penultimate search code, but most likely in the output of the information to text
Makar, why doesn't the highlighted condition work?
Makar, tell me why the highlighted condition doesn't work.
In this line you find the maximum ticket
if(OrderTicket() > penultimate_ticket)
and in this line you're comparing the maximum to the maximum.
if(penultimate_ticket < GetTicketMaxOrder())
therefore always falseWe have never said anything about an error in the code. I will repeat once again, this code works when a new maximum order is opened and when this does not happen, the Expert Advisor considers that the penultimate order = the last one. That is all
This only happens if the EA is restarted
This is only if the EA is restarted
No Makar, look here, I put the variable of the penultimate order and the function of the last order on the monitor
On this line you find the maximum ticket
and in this line you compare the maximum with the maximum.
therefore always falseWell, how do you make it so that all the tickets scanned by this function
to remove a ticket equal to
GetTicketMaxOrder()
Makar, tell me why the highlighted condition doesn't work
Eugene, where does the ticket variable change? Or does the whole loop work with one order?
Eugene, where does the ticket variable change? Or does the whole loop work with one order?
No Makar, look here, I put the variable of the penultimate order and the function of the last order on the monitor
Once again... I gave you a working code!
Run it in the tester and press the buttons.
To see it, you have to make the orders close and this EA does not do that. And the whole problem happens after the max order is closed