not able to apply template in newly opened chart

 

Hi

Kindly help me applying template in newly opened chart.

it is throwing an error message err 4051 invalid function parameter value.

CurrentOpenedChartId=ChartOpen("EURUSD",1);

     

     if(FileIsExist("MA.tpl"))

     {

      Print("The file MA.tpl found in \\Files'");

      //--- apply template

      if(ChartApplyTemplate(CurrentOpenedChartId,"\\Files\\MA.tpl"))

        {

         Print("The template 'MA.tpl' applied successfully");

        }

      else

         Print("Failed to apply 'MA.tpl', error code ",GetLastError());

     }

    else

     {

      Print("File 'MA.tpl' not found in "

            +TerminalInfoString(TERMINAL_PATH)+"\\MQL4\\Files");

     }

//--- 

 

Does the template work if you load it manually ?

 
Marco vd Heijden:

Does the template work if you load it manually ?

Template works fine when I add it manually.

I want to open a new chart EURUSD M1 and apply the template MA.tpl through code.

Kindly help.. 

 

I do not have the MA.tpl but i tried with Volume.tpl and this works fine... i had to copy the Volume.tpl from template folder to the Files folder do.

   long CurrentOpenedChartId=ChartOpen("EURUSD",1);

   if(FileIsExist("Volume.tpl"))
     {
      Print("The file Volume.tpl found in \\Files'");
      //--- apply template
      if(ChartApplyTemplate(CurrentOpenedChartId,"\\Files\\Volume.tpl"))
        {
         Print("The template 'Volume.tpl' applied successfully");
        }
      else
         Print("Failed to apply 'Volume.tpl', error code ",GetLastError());
     }
   else
     {
      Print("File 'Volume.tpl' not found in "
            +TerminalInfoString(TERMINAL_PATH)+"\\MQL4\\Files");
     }
 
Marco vd Heijden:

I do not have the MA.tpl but i tried with Volume.tpl and this works fine... i had to copy the Volume.tpl from template folder to the Files folder do.

Thanks a lot buddy. Now its working........

Instead of long data type , I was using int.

Thanks again. 

Reason: