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
these are your words, there are no warnings, but there really are
What world do you live in, what do you smoke, share
So you so boldly assert for me about my code which you do not see? Are not you mistaken mushrooms?
I got it, not a fool, you have a special compiler without warnings, specially personally from MQ
PS: I want one too, let me use it.
The code you gave is not correct at all!
It should be like this:
Wrong, because then there's a comparison:
No, it's not.
This has nothing to do with it.
The codewriter just overreacted or copied the type conversion from somewhere.
as a matter of fact
code
does not generate any error or warning.
MQL does not require an explicit conversion
PS. Test your assumptions before you start arguing.
a very bad example, you slip up on a comparison and then you run into error:
PS. Test your assumptions before you start arguing.
No, you're not.
It has nothing to do with it.
The codewriter just overreacted or copied from somewhere else .
as a matter of fact
code
does not generate any error or warning.
MQL does not require explicit conversion
PS. Test your assumptions before you start arguing.
o_o!
Right - wrong....
I get the impression that you do not read what others write!
According to programming rules:
THE ACCEPTING FUNCTION VARIABLE MUST BE OF THE SAME TYPE AS THE RETURN VALUE OF THIS FUNCTION!
THAT'S IT!
This is the end of this speculation.
Why didn't you write it this way?
Because you know that the function always returns LONG.
And the reference clearly says thatthe value returned for the argument POSITION_TYPE of thePositionGetInteger() function is
is ENUM_POSITION_TYPE, not LONG
And if you want to practice type casting, write it this way:
The fact that the compiler doesn't give you an error does not mean that you wrote it correctly!
It indicates the compiler's "free will" and that's all! (It allows you to compare LONG and INTEGER).
This is the RIGHT way to handle this situation:
A very bad example, you missed the comparison, and then you will get an error:
Did you see somewhere about further with type conversion? Don't justify your theses by referring to a different subject of the discussion.
This is only about comparison and only in this case long is enum.
You already entered the thicket of thoughts, although the question was direct, which was answered by integer
Nextor257:
Please advise, I cannot understand what kind of comparison this is?
if(type==(long)POSITION_TYPE_BUY)
Why is (long) preceded by POSITION_TYPE_BUY ?
This is a change of the variable type on the fly.
long and lon instead ofENUM_POSITION_TYPE andENUM_POSITION_TYPE
8 characters (which you can type with your eyes closed) instead of 36 characters (and in uppercase)! On top of that there's all sorts of information that doesn't make sense. This is not a good programming style - unnecessary writing and redundant information.
In this case, Mikhail is absolutely right (With all my disgust at Mikhail's programming style).
And it's not about potential warnings and moreover about the number of characters, but about strict typing. The ENUM_POSITION_TYPE enumeration is a unique data type. It is ENUM_POSITION_TYPE, not long or int. You must use it as ENUM_POSITION_TYPE and in no other way. And if you type long, the auto-complete function will start at the third character, and there is no problem at all. And the problem is in using long, because it can be almost anything, while ENUM_POSITION_TYPE is not.
MQL does not require an explicit conversion
At first I wrote that it does, but then I saw the word "comparison". Actually, no explicit conversion is needed in comparison because MQL does it implicitly. And it'd better not do it at all, because the result is often undefined. But in other normal strictly typified languages an explicit type conversion is always required.
P.S. For once Michael gave a competent answer, but people got accustomed to blaspheming him here too. And in vain, because he is right in this case.
How do I withdraw, please?
You can withdraw earned funds from your MQL5 account here: https://www.mql5.com/en/users/syahwal/accounting/chooseout