It is bad practice to use ObjectsDeleteAll, as objects not drawn by the indicator will also be deleted.
string Name=WindowExpertName();
I normally name my objects beginning with WindowExpertName(), then loop through the objects and delete those that begin with it in deinit
for(int i=ObjectsTotal()-1;i>=0;i--) { string ObName=ObjectName(i); if(StringFind(ObName,Name,0)!=-1) ObjectDelete(ObName); }
Check for an array out of range error as this can stop the indicator without executing deinit.
for(int x=0;x<9;x++) { if (iMA (Symbol(),period[x], MA_Period,0,MA_method,PRICE_CLOSE,1) > iMA (Symbol(),period[x], MA_Period,0,MA_method,PRICE_CLOSE,2)) ObjectSetText("signal"+x+"0",CharToStr(236),fontSize,"Wingdings",LimeGreen); else ObjectSetText("signal"+x+"0",CharToStr(238),fontSize,"Wingdings",Red); }
That is probably it.
period[] only has 5 elements, you are trying to access 9
That is probably it.
period[] only has 5 elements, you are trying to access 9
Fixed
Thanks GumRai
It is bad practice to use ObjectsDeleteAll, as objects not drawn by the indicator will also be deleted.
I normally name my objects beginning with WindowExpertName(), then loop through the objects and delete those that begin with it in deinit
Check for an array out of range error as this can stop the indicator without executing deinit.
ObjectsDeleteAll(0,Name);
Thanks Zirkoner

- 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 am new to mql4 coding. This is my first indicator using arrays and I'm having problems with the object delete function, its not removing indicator after removing from the chart?
I have looked everywhere for a solution I can't see how this is not working, does anyone know what needs changing below?
Thanks in advance