In this video, we are going to create an Expert Advisor that can use a so-called enumeration list of values that can be picked by a user without the need to recompile the code. So let’s find out how to do that with MQL4. To get started please click on the little button here or press F4 on your keyboard.


Now you should see the Metaeditor window and you want to click on file, new file, Expert Advisor from template, continue. I will call this file simple multiple input. Click on continue, continue and finish. Now you can delete everything above the ontick function and let’s also remove the two comment lines here, we start by creating a list. The list should contain some entry signals. And if you mark this key word here and press F1, you will see that enumerations are there for a limited set of data that can be predefined, for example, for a list of months.


We want to do that for a list of entry signals. And it’s also possible to assign a value here. So the first item is for random entries and we assign the value zero. The values are separated with commas. The next one would be for the EMA. That would be a value of one and so on. The list is short here because this is just a simple example. We could use a much longer list. The next step is to create an instance of that list.


Don’t forget the modifier input here because this key word is used to make it available for the user and you can afterwards change the values in the Expert Advisor properties. Our list will be called choice and the default value will be random. I would also like to add a readable version so I create a string variable that is called entry. And inside of the ontick function we will check if the choice is equal to zero. That is the default value. And if that is true, we set the entry to random for the other entries in our list it is very similar. We always check for the value, we check for a value here and assign an entry type to our entryle variable. To check what is going on, we need to add a comment statement that will output the entry and the choice values directly on our chart. Usually you would add a few more functions here to handle all the different entries. But this is just to show how you can use enumerations as input variables. So for this simple example, this is enough, that’s basically it.


If this was too fast for you or if you have no idea what all the code here does, maybe you want to watch one of the other videos or maybe even the Premium Course on our website might be interesting for you. That’s also where we have a link for some video courses that also contain those source code files that you can download. If you don’t want to type all that stuff. For now, please click on the Compile button or press F7 on your keyboard.


That should work without any errors. And if that is the case, you can click on a little button here or press F4 to go back to Metatrader. And in Metatrader we pick an empty live chart. Please navigate to the file called simple multiple input and drag it on your chart. And here’s our choice box. We can pick one of the values that we have defined. By the way, this once again was an idea of a Premium Course member, and if you are a Premium Course member and have an idea for a video like this one, please let me know.


So let’s pick a value here and click on, OK! And when the next day comes and we should see that we have picked the EMA value, that happened right now, the value for the choice is one. Now you can press F7. Change the value here, so let’s pick the ADX entry, click on OK, and right away we have a new value here for the entry and for the choice. So our little Expert Advisor is working as expected.


And in this little video, you have learned how you can use an enumeration list of values to allow a user defined input without the need to recompile the code. And you have coded it yourself with a few lines of MQL4 code.