MT5 - ChartApplyTemplate() applies template, but EA's auto-trading is disabled

 

From a pushbutton on a chart, I open a new chart:

long newChart = ChartOpen(pair, PERIOD_D1);

then apply a template (which is defined with an EA on it):

if ( ! ChartApplyTemplate(newChart,InpTemplateName) )
{
        PrintFormat("Failed to apply template [%s] to chart [%d]", InpTemplateName,newChart);
        return;
}

But the EA has auto trading disabled.

EA disabled

If I apply the template manually through the terminal, it's enabled.

enabled

My global settings are: Allow automated trading.

all good things


Any thoughts on how to programmatically open a new chart, apply a template, and have the EA's auto trading enabled?
 

1° Is your running code (opening a new chart and applying a template) an EA or a script ? An indicator has no right to trade.

2° Is your running code has specific "Allow automated trading" ?

3° Is your template saved with automated trading enabled ?

 
Alain Verleyen:

1° Is your running code (opening a new chart and applying a template) an EA or a script ? An indicator has no right to trade.

2° Is your running code has specific "Allow automated trading" ?

3° Is your template saved with automated trading enabled ?

Oooh! 1° looks like the answer. It's an indicator.

Thank you for your response.

Reason: