Alberto Tortella:
Hi all, I have a strange error when my expert tries to close an order.
I'm sure the condition is met, because I see the "Check" output in the Expert tab.
The problem is that GetLastError() function return "0".
Have you got a suggestion on how to find the problem?
Thank you!
Try this one....
if(Bid>=GlobalVariableGet(StringConcatenate("Take_Profit_1_",OrderTicket()))) { Print("Check"); if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,PaleGoldenrod)) { Print("Error closing BUY order @ ratio 1: ",GetLastError()); return; } }
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014

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
Hi all, I have a strange error when my expert tries to close an order.
I'm sure the condition is met, because I see the "Check" output in the Expert tab.
The problem is that GetLastError() function return "0".
Have you got a suggestion on how to find the problem?
Thank you!