Does it matter?
It's not anything fatal, but can be very problematic. That's like asking if timezones matter.
(Especially if all other built-in enums like ENUM_MA_METHOD or ENUM_APPLIED_VOLUME do follow the rule and start at 0)
After getting some trouble reading custom indicators that use the enum "ENUM_APPLIED_PRICE" I noticed that its first value (PRICE_CLOSE) was 1, instead of 0 as usual.
In MQL4 the documentation especifies its values from 0 to 6 , but in MQL5 they aren't explicit .
void OnStart()
{
for (int i=0; i<=8; i++)
Print("i = ", i, " ", EnumToString((ENUM_APPLIED_PRICE)i));
}
Is there any reason for that?
This is why you should always refer to by name and not by value. At any time, the numbering inside the structure can be changed and you will burn out badly in the fall. But those who refer to the structure by name will not have any problems.
Does it matter?
Hi Keith, it does under some circumstances where you cannot use the enumerator, like when applying to a combobox, so you then have to write a translation peice of code. The inconsistency between mql4 and mql5 on this is clearly an oversite and ideally would be corrected, but last time I mentioned it I got all the usual defensive responses of not a bug, does not matter etc. but the idea of an enum is to avoid translation code and make things easier to understand, and the point of having a unified mql4/5 compiler is for compatability... things like this just become a pain to discover and work around and don't fulfil those ideals.
That said if they just shut MT4 down then it wouldn't be a problem anymore :)
Hi Keith, it does under some circumstances where you cannot use the enumerator, like when applying to a combobox, so you then have to write a translation peice of code. The inconsistency between mql4 and mql5 on this is clearly an oversite and ideally would be corrected, but last time I mentioned it I got all the usual defensive responses of not a bug, does not matter etc. but the idea of an enum is to avoid translation code and make things easier to understand, and the point of having a unified mql4/5 compiler is for compatability... things like this just become a pain to discover and work around and don't fulfil those ideals.
That said if they just shut MT4 down then it wouldn't be a problem anymore :)
There is no problem - as people work with MQL5, and the old terminal was thrown out long ago.
There is no problem - as people work with MQL5, and the old terminal was thrown out long ago.
This is why you should always refer to by name and not by value. At any time, the numbering inside the structure can be changed and you will burn out badly in the fall. But those who refer to the structure by name will not have any problems.
That's true, and ideally when using a concrete indicator in an expert advisor is preferable, but I usually test multiple indicators and going into the specifics of each one would take me much more time (I won't go much into that)
This is my biggest concern, that any enum could just be changed without any reason. It's pretty impractical from a programming point of view...
***
This is my biggest concern, that any enum could just be changed without any reason. It's pretty impractical from a programming point of view...
Personally, I would do this on purpose - to teach people like you to refer to ENUM by name, and not by value :)
This is your problem - you are not working correctly with ENUM. As a rule, such mistakes are made by those who are sitting at the old terminal. As soon as you throw the old terminal in the trash, you will begin to program better.
Personally, I would do this on purpose - to teach people like you to refer to ENUM by name, and not by value :)
This is your problem - you are not working correctly with ENUM. As a rule, such mistakes are made by those who are sitting at the old terminal. As soon as you throw the old terminal in the trash, you will begin to program better.
Then MQL5 developers should consider adding a parameter "enum_applied_price_value" to the MqlParam struct :) (And a TYPE_APPLIED_PRICE to ENUM_DATATYPE)...
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
After getting some trouble reading custom indicators that use the enum "ENUM_APPLIED_PRICE" I noticed that its first value (PRICE_CLOSE) was 1, instead of 0 as usual.
In MQL4 the documentation especifies its values from 0 to 6, but in MQL5 they aren't explicit.
void OnStart()
{
for (int i=0; i<=8; i++)
Print("i = ", i, " ", EnumToString((ENUM_APPLIED_PRICE)i));
}
Is there any reason for that?