Download MetaTrader 5
To add comments, please log in or register
Are you a good trader? Become a signals provider and make even more money!
Dua Yong Rew
5397
Dua Yong Rew 2016.10.21 15:55 

Hi All,

I have some issue trying to apply template to charts that I open using my script. The charts open but the template don't apply when I use ChartApplyTemplate

Here is the code.

 

For loop
{
...

      if(ShowChart && TradeSig)
      {
         ChartOpen(FX_Pairs[i], PERIOD_D1);
         ChartApplyTemplate(0, "\\kiss.tpl");
      }
}
Jose Francisco Casado Fernandez
2415
Jose Francisco Casado Fernandez 2016.10.22 14:02  
Dua Yong Rew:

Hi All,

I have some issue trying to apply template to charts that I open using my script. The charts open but the template don't apply when I use ChartApplyTemplate

Here is the code.

 

For loop
{
...

      if(ShowChart && TradeSig)
      {
         ChartOpen(FX_Pairs[i], PERIOD_D1);
         ChartApplyTemplate(0, "\\kiss.tpl");
      }
}

Do you have a template with that name inside 'terminal_data_path\MQL5' or inside 'terminal_path\Profiles\templates' ?.

In the other hand, 0 denotes the current chart. If you have a template with that name, it would apply to the current chart, and not to the new opened chart. You would have to replace 0 by the new chart ID. Example:


long chart = 0;

For loop
{
...

      if(ShowChart && TradeSig)
      {
         chart = ChartOpen(FX_Pairs[i], PERIOD_D1);
         if(chart > 0)

         {

         ResetLastError();

         if(!ChartApplyTemplate(chart, "\\kiss.tpl"))
         PrintFormat("Failed to apply template to %I64d,  error code: %d", chart, GetLastError());
         else
         ChartRedraw(chart);
         }
      }
}


Regards

Dua Yong Rew
5397
Dua Yong Rew 2016.10.24 00:36  
Jose Francisco Casado Fernandez:

Do you have a template with that name inside 'terminal_data_path\MQL5' or inside 'terminal_path\Profiles\templates' ?.

In the other hand, 0 denotes the current chart. If you have a template with that name, it would apply to the current chart, and not to the new opened chart. You would have to replace 0 by the new chart ID. Example:


long chart = 0;

For loop
{
...

      if(ShowChart && TradeSig)
      {
         chart = ChartOpen(FX_Pairs[i], PERIOD_D1);
         if(chart > 0)

         {

         ResetLastError();

         if(!ChartApplyTemplate(chart, "\\kiss.tpl"))
         PrintFormat("Failed to apply template to %I64d,  error code: %d", chart, GetLastError());
         else
         ChartRedraw(chart);
         }
      }
}


Regards

Thanks, Let me try that
/
To add comments, please log in or register