Something wrong with this very simple indicator

 

Hey guys, I was hoping can point me in the right direction:

I'm trying to code a very simple indicator that loads at a specified time a specified template. But somehow mt4 is keep telling me that the template file is not found, even though I made sure its there and that it's spelled out correctly. I have to assume its something with the code. Can someone take a look and tell me whats wrong with my code?

#property indicator_chart_window

extern string tplFileName = "YourTemplateName.tpl";  
extern int targetTime = 0; 

int start()
{
    datetime currentTime = Time[0];

    int targetHour = targetTime / 100;
    int targetMinute = targetTime % 100;

    if (TimeHour(currentTime) == targetHour && TimeMinute(currentTime) == targetMinute)
    {
        string tplPath = TerminalInfoString(TERMINAL_DATA_PATH) + "\\templates\\" + tplFileName;

        if (FileIsExist(tplPath))
        {
            ChartApplyTemplate(0, tplPath);
        }
        else
        {
            Print("Template file not found: ", tplPath);
        }
    }

    return 0;
}
 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
CarlJimson00:

Hey guys, I was hoping can point me in the right direction:

I'm trying to code a very simple indicator that loads at a specified time a specified template. But somehow mt4 is keep telling me that the template file is not found, even though I made sure its there and that it's spelled out correctly. I have to assume its something with the code. Can someone take a look and tell me whats wrong with my code?

In MQL4 files must be in the "Files" folder.

See "Note".

https://docs.mql4.com/files/fileisexist

For that file,

(1) Put it in the "Files" folder.

(2) Create a subdirectory in the "Files" folder and put it there.

(3) Create a symbolic link to the "templates" folder in the "Files" folder.

(2) and (3) have not been confirmed to work, but they are probably OK.