You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It is obvious that MT5 Templates cannot store all objects that can be automatically created using the ObjectCreate() function.
According to the documentation, 44 objects can be created using the ObjectCreate() function:
https://www.mql5.com/en/docs/objects/objectcreate
So, I took the next steps to find out those objects that cannot be saved automatically to templates:
1. I created an expert advisor that creates all 44 objects.
2. I added the expert advisor to a blank chart that does not contain any other objects.
3. I saved the chart to a new template.
4. I applied the template to a new chart.
5. I opened the template in the Meta Editor to see if all objects are saved inside the template code.
6. I found that the template did not save those objects: Button - Bitmap Label – Edit - Rectangle Label
Conclusion.
For some reason, the templates in MT5 cannot store some objects that are created automatically using the ObjectCreate() function. Those objects are:
I hope MQL5 developers can take a look at this issue because it affects templates, which are an important ingredient in the platform.
I hope MQL5 developers can take a look at this issue because it affects templates, which are an important ingredient in the platform.
What do you need OBJ_BUTTON and OBJ_EDIT for in the template? These objects should be created by the MQL program that will process the user's interaction events with them.
It is obvious that MT5 Templates cannot store all objects that can be automatically created using the ObjectCreate() function.
According to the documentation, 44 objects can be created using the ObjectCreate() function:
https://www.mql5.com/en/docs/objects/objectcreate
So, I took the next steps to find out those objects that cannot be saved automatically to templates:
1. I created an expert advisor that creates all 44 objects.
2. I added the expert advisor to a blank chart that does not contain any other objects.
3. I saved the chart to a new template.
4. I applied the template to a new chart.
5. I opened the template in the Meta Editor to see if all objects are saved inside the template code.
6. I found that the template did not save those objects: Button - Bitmap Label – Edit - Rectangle Label
Conclusion.
For some reason, the templates in MT5 cannot store some objects that are created automatically using the ObjectCreate() function. Those objects are:
I hope MQL5 developers can take a look at this issue because it affects templates, which are an important ingredient in the platform.
This is by design and will not be changed, according to MQ developers. The reason for this is to not save programmatically created objects in templates, because such objects are treated as controlled by MQL5-program which created them. This is already mentioned on the thread.
If you want for some reason to treat programmatically created objects as manually created, you should explicitly apply the following property to them:
If you do so for your test EA, you'll get template with all objects.
The origin (the russian forum):
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Новая версия платформы MetaTrader 5 build 4000: Улучшения в торговом отчете и веб-терминале
Slava, 2023.10.18 15:47
I just took another look at the source code responsible for saving objects to the template. The code was written a long time ago, and it is unlikely to be changed.
So, one of the conditions is simultaneous hiding and non-selectability.
It is not known when we will change this behavior, since the problem is not widespread. And this behavior was specially programmed so that graphic panels always work without problems
This is by design and will not be changed, according to MQ developers. The reason for this is to not save programmatically created objects in templates, because such objects are treated as controlled by MQL5-program which created them. This is already mentioned on the thread.
If you want for some reason to treat programmatically created objects as manually created, you should explicitly apply the following property to them:
If you do so for your test EA, you'll get template with all objects.
The origin (the russian forum):
1. Thanks a lot for your interest, Stanislav. I hope that you understand that my intention from all this conversation is to make MT5 better.
2. I think that the comment of “Slava” confirms my point that the MT5 templates code needs to be updated ... At least, that is what he said in his comment.
3. Your solution will solve the problem for the “Rectangle Label,” but it won’t work for other objects like “Buttons.” If I change the OBJPROP_SELECTABLE to true, the buttons will not be clickable.
For a button to be clickable, the OBJPROP_SELECTABLE should be false and vice versa.
4. Templates are very important and a lot of MT5 users depend on them every day. I hope our developers upgrade soon.
Best regards
1. Thanks a lot for your interest, Stanislav. I hope that you understand that my intention from all this conversation is to make MT5 better.
2. I think that the comment of “Slava” confirms my point that the MT5 templates code needs to be updated ... At least, that is what he said in his comment.
3. Your solution will solve the problem for the “Rectangle Label,” but it won’t work for other objects like “Buttons.” If I change the OBJPROP_SELECTABLE to true, the buttons will not be clickable.
For a button to be clickable, the OBJPROP_SELECTABLE should be false and vice versa.
4. Templates are very important and a lot of MT5 users depend on them every day. I hope our developers upgrade soon.
The main idea of what Slava said was highlighted in my previous post with a quote, and sounds like "we'll not change this".
Our thoughts on what needs to be updated are not similar to what MQ thinks most of the time. This is just one of numerous examples.
If you don't want to enable OBJPROP_SELECTABLE (set to true), you can disable OBJPROP_HIDDEN (set to false) as a workaround.