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
This will most likely work, but it's best not to do it. You request the same error from the terminal 2 times and do it in two different ways. At the very least, this is not logical and may confuse you in the future. By storing the GetLastError value in a variable, you are guaranteed to use the same value in both the if statement and the Print function.
I agree.
I got this and thanks for this code but what the issue with my this code :
Is this correct, here i am not calling GetLastError on if statement
Perhaps you should read the manual. GetLastError - Checkup - MQL4 Reference
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
The second call always returns zero.
After the function call, the contents of _LastError are reset.
the __FUNCTION__ is always equal.
Thanks for this information.
This code is perfect?
Forum on trading, automated trading systems and testing trading strategies
GetLastError with Function name using if statement
anuj71, 2024.02.19 10:20
@anuj71 used both GetLastError and _LastError. This is why I suggested using a variable. If @anuj71 explicitly reset the error using GetLastError, then ok.
In any case, I think it's better to use either GetLastError only or _LastError only. And I would suggest adding ResetLastError before OrderModify
[EDIT]
By "GetLastError only" I mean assigning the value of GetLastError to a variable
I would suggest adding ResetLastError before OrderModify
Like this?
Yes, I think ResetLastError before OrderModify would be appropriate. Now you can be sure that if you find an error (in an if statement), that error occurred in OrderModify
Yes, I think ResetLastError before OrderModify would be appropriate. Now you can be sure that if you find an error (in an if statement), that error occurred in OrderModify
Thanks for this information.
This code is perfect?