How to ttach EA in a template using code

 
I need to attach an EA to a template that I am creating using the ChartSaveTemplate function, but I don't know what function is used to attach the EA. For example, I have seen indicators are attached using the iCustom function, but I have not found any indication to do the same with expert advisors.
Thank you very much
 
luislmv85 I have seen indicators are attached using the iCustom function, but I have not found any indication to do the same with expert advisors.
There is no difference; templates can have either or both.
 
William Roeder:
There is no difference; templates can have either or both.

OK thanks. But I am confused. After using the iCustom function, you need to add the EA with the ChartIndicatorAdd function.It is valid?

void OnStart()
{
   long chart;
   int h;
   h=iCustom(NULL,0,"C:\Program Files\MetaTrader\MQL5\Experts\EAexample");
   ChartIndicatorAdd(0,1,h);
   ChartRedraw();
   ChartSaveTemplate(0,"pru");
   chart = ChartOpen("EURUSD",15);
   ChartSetInteger(chart,CHART_SHOW_OBJECT_DESCR,true);
   if(chart!=0)
     {
      ChartApplyTemplate(chart,"pru");
     }
  }
This does not work. I want to load an EA in a new chart.

Thank you very much

 
luislmv85:

OK thanks. But I am confused. After using the iCustom function, you need to add the EA with the ChartIndicatorAdd function.It is valid?

This does not work. I want to load an EA in a new chart.

Thank you very much

I think there is an extensive article somewhere here. Try looking it up

 
luislmv85: But I am confused. After using the iCustom function, you need to add the EA with the ChartIndicatorAdd function.It is valid?This does not work. I want to load an EA in a new chart.

Start asking a proper question. Stop asking how do I do this with this, and start stating what are you trying to do.
          How To Ask Questions The Smart Way
          The XY Problem

Your code adds an indicator to the current chart and saves a template, then opens another chart and applies the template. A) That will not work, it takes time for the chart to open, and you have no delay. B) If the current chart doesn't already have the EA on it, neither does the template and then other chart.

Setup a chart the way you want it (including the EA) and save the template. Then you can have code open another chart and apply it, or have it applied by default. The template ordering for new charts is «EAname».tpl, (if tester) tester.tpl, (if offline chart) offline.tpl, and Default.tpl.

Or drop your code completely and just open another chart. What are you trying to do?