# how is enum used?

hi guys,

i'm going through the help doc of mql5 and am reading about enum here https://www.mql5.com/en/docs/basis/types/integer/enumeration

however there's no examples of how they're used.

all I got is that one can create a list which will be assigned values from 0 with increments of 1s but thats it...

The next topic/chapter in the help is about the double/float variable, so not sure if i'm missing something or more about enum will come up in later help topics.

L

Documentation on MQL5: Language Basics / Data Types / Integer Types / Enumerations
• www.mql5.com
Enumerations - Integer Types - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

zelda_lee: i'm going through the help doc of mql5 and am reading about enum here https://www.mql5.com/en/docs/basis/types/integer/enumeration. however there's no examples of how they're used.

all I got is that one can create a list which will be assigned values from 0 with increments of 1s but thats it... The next topic/chapter in the help is about the double/float variable, so not sure if i'm missing something or more about enum will come up in later help topics.

What do you mean there are no examples? There are two examples on that page and enumerations are used in many MQL functions, so there is even more examples all over.

Besides, we live in the world of the internet where there are many websites out there that explain what enumerations are in C and C++ just as the documentation mentions.

EDIT: Here is another example in the documentation on how it is used ... https://www.mql5.com/en/docs/basis/variables/inputvariables

In the example, an enumerations for the types of moving averages is explained ...

`input ENUM_MA_METHOD MA_Method=MODE_SMMA; // Method`

ENUM_MA_METHOD

ID

Description

MODE_SMA

Simple averaging

MODE_EMA

Exponential averaging

MODE_SMMA

Smoothed averaging

MODE_LWMA

Linear-weighted averaging

Documentation on MQL5: Constants, Enumerations and Structures
• www.mql5.com
Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

@Fernando Carreiro Yes there are 2 examples but they're limited to how to create an enum list not how to use it.

Now i figured out you can create a new variable of the enum type of get the index pointer of the value assigned to it from the list.

Also your links show it can be used for drop down list so thank you for that

zelda_lee #: Yes there are 2 examples but they're limited to how to create an enum list not how to use it. Now i figured out you can create a new variable of the enum type of get the index pointer of the value assigned to it from the list. Also your links show it can be used for drop down list so thank you for that
You are welcome!
Reason: