Hi all,
Has anyone successfully automated the process of loading templates onto multiple open charts in MT4?
I've read through many suggestions on this forum and tried several approaches, but haven’t found a working solution. I had ChatGPT generate a script that opens three charts and applies a template to each, but the templates fail to load.
ChatGPT reviewed the code and confirmed it’s syntactically correct. However, it also pointed out that the issue may be due to the Templates folder being set to “read-only” (as seen via File -> Open Data Folder -> templates -> Properties). This could be preventing the templates from being applied.
Has anyone figured out a reliable method to open multiple charts and apply a specific template to each one successfully?
Here’s a simplified snippet of the code I’m using to apply the template:
mq4
Copy
Edit
#property strict
void OnStart()
{
string templateName = "MarkO";
string path = TerminalInfoString(TERMINAL_DATA_PATH) + "\templates\" + templateName + ".tpl";
if (!FileIsExist(path))
{
Print("Template not found at: ", path);
return;
}
if (!ChartApplyTemplate(ChartID(), templateName))
Print("Failed to apply template to current chart.");
else
Print("Template applied to current chart.");
}
Any ideas or working examples would be much appreciated.
Thanks,
MarkO