MQL5 Templates - Saving a template w/ EA also saves <objects>

 

This is only a minor annoyance.

Steps:

  1. Start with a "clean" chart. That is, just bars, no other indicators.
  2. Start EA with a dialog on it created from CAppDialog. This EA has labels, edits, buttons, etc.
  3. Save as Template.

For some reason, the labels are stored in the .tpl file. For example:

<object>
type=102
name=20532LabelSetup
hidden=1
descr=Setup:
color=2631995
selectable=0
angle=0
pos_x=135
pos_y=155
fontsz=10
fontnm=Trebuchet MS
anchorpos=0
refpoint=0
</object>

<object>
type=102
name=20532LabelType
hidden=1
descr=Type:
color=2631995
selectable=0
angle=0
pos_x=135
pos_y=205
fontsz=10
fontnm=Trebuchet MS
anchorpos=0
refpoint=0
</object>

Thus, any time I use the template, I get all these artifacts.

It only saves the labels objects. These are standard CLabel objects, e.g.

        CLabel                          m_label_setup;
        CLabel                          m_label_type;

I can easily go into the .tpl file and remove the artifacts, which is why I say this is only a minor annoyance, but I am wondering if I am missing the right way of doing things.

 
You can use sorcery - manually delete the objects before saving the template or create an empty expert, rename it for a while as the needed one and save the template with it.
 
Anthony Garot:

This is only a minor annoyance.

Steps:

  1. Start with a "clean" chart. That is, just bars, no other indicators.
  2. Start EA with a dialog on it created from CAppDialog. This EA has labels, edits, buttons, etc.
  3. Save as Template.

For some reason, the labels are stored in the .tpl file. For example:

Thus, any time I use the template, I get all these artifacts.

It only saves the labels objects. These are standard CLabel objects, e.g.

I can easily go into the .tpl file and remove the artifacts, which is why I say this is only a minor annoyance, but I am wondering if I am missing the right way of doing things.

It is how templates are working.

Doing it by code, you could save the template as you want. For example, save the template, then read it and write it again filtering all objects.

 
Anthony Garot: For some reason, the labels are stored in the .tpl file.

Saving a template saves everything. That is your "some reason."

 
Anthony Garot:

This is only a minor annoyance.

Steps:

  1. Start with a "clean" chart. That is, just bars, no other indicators.
  2. Start EA with a dialog on it created from CAppDialog. This EA has labels, edits, buttons, etc.
  3. Save as Template.

For some reason, the labels are stored in the .tpl file. For example:

Thus, any time I use the template, I get all these artifacts.

It only saves the labels objects. These are standard CLabel objects, e.g.

I can easily go into the .tpl file and remove the artifacts, which is why I say this is only a minor annoyance, but I am wondering if I am missing the right way of doing things.

For me to save this as a template it would be like driving 100mph and decided to switch gear to park without slowing down first :)  ... CAppDialog = live interface   ...if would be like take a screenshot of your desktop and expect to work as a full system when displayed on another computer :) .

 
Marcin Rutkowski:

For me to save this as a template it would be like driving 100mph and decided to switch gear to park without slowing down first :)  ... CAppDialog = live interface   ...if would be like take a screenshot of your desktop and expect to work as a full system when displayed on another computer :) .

I save EA's as templates so that I can restart them quickly with specific input settings. Because of the stored inputs, Templates are more flexible than "Favorites."
 
William Roeder:

Saving a template saves everything. That is your "some reason."

Well, sort of, but no.

Templates saves some objects, e.g. experts, indicators, and labels. It appears that anything one could create manually using the "Line Studies" toolbar.

But templates do not save all objects, e.g. Buttons, Edits, Bitmap Labels, nor Rectangle Labels.

 
Alain Verleyen:

It is how templates are working.

Doing it by code, you could save the template as you want. For example, save the template, then read it and write it again filtering all objects.

Yes, that would work.