Applies a specific template from a specified file to the chart. The command is added to chart messages queue and will be executed after processing of all previous commands.
[in] Chart ID. 0 means the current chart.
[in] The name of the file containing the template.
The Expert Advisor will be unloaded and will not be able to continue operating in case of successful loading of a new template to the chart it is attached to.
When applying the template to the chart, trade permissions may be limited due to security reasons:
If the mql5-program calling ChartApplyTemplate() function has no permission to trade, the Expert Advisor launched via the template will also not be able to trade regardless of the template settings.
If the mql5-program calling ChartApplyTemplate() function has permission to trade, while there is no such permission in the template settings, the Expert Advisor launched via the template will not be able to trade.
The resources of the MQL5 language allow setting multiple chart properties, including colors using the ChartSetInteger() function:
Besides, there can be multiple graphical objects and indicators on a chart. You may set up a chart with all the necessary indicators once and then save it as a template. Such a template can be applied to any chart.
The ChartApplyTemplate() function is intended for using a previously saved template, and it can be used in any mql5 program. The path to the file that stores the template is passed as the second parameter to ChartApplyTemplate(). The template file is searched according to the following rules:
Here terminal_directory is the folder from which the MetaTrader 5 Client Terminal is running, and terminal_data_directory is the folder, in which editable files are stored, its location depends on the operating system, user name and computer's security settings. Normally they are different folders, but in some cases they may coincide.
The location of folders terminal_data_directory and terminal_directory can be obtained using the TerminalInfoString() function.
Templates are not resources, they cannot be included into an executable EX5 file.