Input storage classes are global variables and must be declared outside of blocks and functions. In the concept of MQL4 and MQL5, these input storage classes are also often named “external variables” as these variables are accessible externally from the code. The purpose of these external variables is to provide an interface to tweak and modify the parameters of your robot or expert advisor without altering the code. External variables can be accessed from the MetaTrader interface as per Fig.47, tab “Inputs.”
Let us take the example of our simple moving average strategy. You would like to test the moving average robot with different periods, for instance, 20, 50, or 100. Instead of modifying the code every time you are running the robot, you can instead change the expert advisor settings from the MetaTrader interface. This allows you to easily implement a trading strategy that can be adapted and tuned to market conditions over time. To access the Expert Advisor’s input tab from MetaTrader, locate the chart where your robot is attached to (Fig.49). The name of the attached Expert Advisor should be displayed in the upper right corner of the chart. From the chart, right-click and select the menu “Expert List” if you are on MetaTrader 5 or “Expert Advisors/Properties” if you are on MetaTrader 4 (Fig.50).
Fig. 50 Access to Expert Advisor’s properties, MetaTrader 5 (left), MetaTrader 4 (right).
In MetaTrader 5, you have an additional step to reveal the Expert Advisor properties, press the button “properties” to reveal the list of input variables from the “Experts dialog” (Fig.51).