I have a special situation...
In an indicator I create a Fibo Object... I want to allow the indicator that is creating the Fibo object to be added multiple times on the chart and that fact forces me to add an index to the Fibo object name in the Init() function for the indicator.
Everything is working fine adding or removing the indicator from the chart but if I save a template containing the indicator it seems to me that the objects saved in the template are first created and after that also the Init() of the indicator is checked...
In Init() for the indicator I have code something like this:
for(int NoFibos=1; NoFibos<=10; NoFibos++)
{
FiboName="FiboObj"+IntegerToString(NoFibos);
if(ObjectFind(0,FiboName) < 0)
{
break;
}
}
... Create the object with the name FiboName...
So in my scenario, I add the indicator once, "FiboObj1" object is created and I save it in a template. When I re-load the template, "FiboObj1" is already found using my code above in the Init() function and the "FiboObj2" is created having now 2 Fibo objects instead of only one as I had when saved the template.
And Yes, my DeInit() function has code to remove all objects and it is working properly removing the objects.
Thank you.
When we save a new template, it saves also all the objects present in the chart and present on every sub-window.
Edit the template after saving it, and remove those objects.
Next time you load the template, the objects will not be created, thus allowing your indicator to create them correctly.
I have a special situation...
In an indicator I create a Fibo Object... I want to allow the indicator that is creating the Fibo object to be added multiple times on the chart and that fact forces me to add an index to the Fibo object name in the Init() function for the indicator.
There is no such macro for initialization reason, try using
https://www.mql5.com/en/docs/chart_operations/chartindicatorname
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a special situation...
In an indicator I create a Fibo Object... I want to allow the indicator that is creating the Fibo object to be added multiple times on the chart and that fact forces me to add an index to the Fibo object name in the Init() function for the indicator.
Everything is working fine adding or removing the indicator from the chart but if I save a template containing the indicator it seems to me that the objects saved in the template are first created and after that also the Init() of the indicator is checked...
In Init() for the indicator I have code something like this:
for(int NoFibos=1; NoFibos<=10; NoFibos++)
{
FiboName="FiboObj"+IntegerToString(NoFibos);
if(ObjectFind(0,FiboName) < 0)
{
break;
}
}
... Create the object with the name FiboName...
So in my scenario, I add the indicator once, "FiboObj1" object is created and I save it in a template. When I re-load the template, "FiboObj1" is already found using my code above in the Init() function and the "FiboObj2" is created having now 2 Fibo objects instead of only one as I had when saved the template.
And Yes, my DeInit() function has code to remove all objects and it is working properly removing the objects.
Thank you.