You have to use OrderSelect() before using OrderTicket()
Read Documentation https://docs.mql4.com/trading/orderticket

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
Hello.
I get an "Invalid ticket for OrderClose() function" (error 4051) when I test my EA. Looking at the error codes I see that a parameter is invalid. Although I have a hunch it is OrderTicket() that is messing up, I have seen this parameter listed like it is in other codes.
The OrderClose() code is written below. Please help.
Thank you,
Mac