ChartApplyTemplate() failed if I use chart ID

 
void OnStart()
{

  int id = ChartID();

  Print(id);

  ChartApplyTemplate(id, "Momentum.tpl");

}

Testing with this simplified script, I proved a problem in my code: I can see id value, but template failed to apply. But if i use ChartApplyTemplate(0,"Momentum.tpl") instead, it works great.

I need to use chartID, where the chart is not the current chart.

So, what is the problem? Please give me a hint.

Documentation on MQL5: Chart Operations / ChartApplyTemplate
Documentation on MQL5: Chart Operations / ChartApplyTemplate
  • www.mql5.com
Applies a specific template from a specified file to the chart. The command is added to chart messages queue and will be executed after processing...
 
joshatt:

Testing with this simplified script, I proved a problem in my code: I can see id value, but template failed to apply. But if i use ChartApplyTemplate(0,"Momentum.tpl") instead, it works great.

I need to use chartID, where the chart is not the current chart.

So, what is the problem? Please give me a hint.

Try

long id=
 
andrew4789 #:
Try

long id=

It works right away. My bad.

Thank you so much.

 
joshatt #:

It works right away. My bad.

Thank you so much.

You're welcome.

But if you using

#property strict

at the start of your ea I think it should create a warning to alert you of that type of error.
 
andrew4789 #:
You're welcome.

But if you using

#property strict

at the start of your ea I think it should create a warning to alert you of that type of error.

Thanks !!!