ChartApplyTemplate()

 

Hello, I want to load a template  to a back-testing chart, but I got an error#5019:ERR_FILE_NOT_EXIST.

Code same as below:

//+------------------------------------------------------------------+
//|                                            test_loadtemplate.mq5 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---    
     if(MQLInfoInteger(MQL_TESTER)) 
     {
      if(!ChartApplyTemplate(0,"ADX.tpl"))  Print("Load ADX.tpl template error# ",GetLastError());
      // error#5019:ERR_FILE_NOT_EXIST
     } 
     
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
     int test = 0;
  }

 Any suggestion is preciated !

 
Any suggestion?
 
Ziheng Zhuang:
Any suggestion?

Where is saved your template ?

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:

  • if the backslash "\" separator (written as "\\") is placed at  the beginning of the path, the template is searched for relative to the path _terminal_data_directory\MQL5,
  • if there is no backslash, the template is searched for relative to the executable EX5 file, in which ChartApplyTemplate() is called;
  • if a template is not found in the first two variants, the search is performed in the folder terminal_directory\Profiles\Templates\.
 
Alain Verleyen:

Where is saved your template ?

It is saved in  terminal_directory\Profiles\Templates\
 
Ziheng Zhuang:
It is saved in  terminal_directory\Profiles\Templates\

So that dosn't work with the Strategy Tester.

You can name a template as your EA (yourEAname.tpl) and it will be loaded automatically.

 
Alain Verleyen:

So that dosn't work with the Strategy Tester.

You can name a template as your EA (yourEAname.tpl) and it will be loaded automatically.

  Thank you.  

   Tested,it is a convenient method. 

Reason: