Hi i write an Indicator that Draw to many rectangle objects on main chart. i want delete all the rectangle after close my indicator.
I use this code but the object not remove and remain on chart
void OnDeinit(const int reason) { int qq=0, if(reason == 1) { while(ObjectFind(Symbol(),"Line"+IntegerToString(qq)) >=0) { ObjectDelete(Symbol(),"Line"+IntegerToString(qq)); qq++; } } }
even debug my code show the code is running but the rectangle is still not remove. how can i fix this? please help
The syntax variable is not correct to delete
Objectdelete(chart_id, name)
//--- Check the reference Guide
In your case, no need for
Symbol()
that is suppose to be the chart id.
No different even when I use 0 for chart_id.
I use the All method of "ObjectsDeleteAll" but that is not working to.
and now when i use blow code to see the result of code execute in d the CE variable is 1.
void OnDeinit(const int reason) { int qq=0, CE =0; if(reason == 1) { while(ObjectFind(Symbol(),"Line"+IntegerToString(qq)) >=0) { CE =ObjectDelete(Symbol(),"Line"+IntegerToString(qq)); qq++; } } }
i try another method. the ObjectDelete work currently in OnInit function. So i Write my code for delete object in OnInit and call this function in onDeinit. Now the object delete after Indicator Close. but Before Closing the indicator I should first go to H1 TimeFrame and not work on another time frame again
Your method may work but it is accidental and not a good method.
You have already been told
The syntax variable is not correct to delete
In your case, no need for
Symbol()
that is suppose to be the chart id.
and yet you have totally ignored the advice.
Your method may work but it is accidental and not a good method.
You have already been told
and yet you have totally ignored the advice.
I am not ignoring advice.
I use this too. But noting change.
void OnDeinit(const int reason) { int qq=0; if(reason == 1) { while(ObjectFind(0,"Line"+IntegerToString(qq)) >=0) { ObjectDelete(0,"Line"+IntegerToString(qq)); qq++; } } ChartRedraw(0); }
I don't know why you have linked to ChartWindowFind() as you do not have to specify the window for ObjectFind() or ObjectDelete().
Just to be totally clear
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi i write an Indicator that Draw to many rectangle objects on main chart. i want delete all the rectangle after close my indicator.
I use this code but the object not remove and remain on chart
even debug my code show the code is running but the rectangle is still not remove. how can i fix this? please help