How To Use Input Variables in Your EA


I created quite a few user inputs like that I want to have as variables, not only in this system but in the EA’s in the future. Having done them, I do not know where to find them to drag and drop them into a drawing, when making my ea.


Good question. Input variables, also known as “extern” variables in MQL, are used to pass settings into the EA each time the EA is started.  (You probably already know that.)

These variables are not meant to be written to while the EA is excuting. Think of them as read-only.  So the variable can be set (written) once when the EA starts, but after that, the value should not change as the EA executes. It should only be read while the EA is running.  (If a variable needs to be read and written to during EA execution, it should not be created as an Input).

The MQL compiler has changed it’s rules regarding input\extern variables over the last few releases: at times throwing an error, other times throwing a warning, and early on, not doing anything. But the intention from MetaQuotes, or MetaTrader, is clear: input variables are meant to be read-only once execution starts.

For this reason, input variables are not available to drag and drop, but they are available to be accessed from any input tab within VTS.  While within a text box, you can type the name and it should appear (this is called intelli-sense). Or you can use the “Inputs” tab on any “Choose” form.

Here is the parameter form for the ATR indicator:

 Click the Choose button to choose a value:


Then select the Inputs Tab to select any of the defined input parameters.

To get notified about the latest questions and answers, follow us!