Try using UninitializeReason( ), REASON_CHARTCHANGE:
https://docs.mql4.com/check/UninitializeReason
https://docs.mql4.com/constants/uninit
Another way off the top of my head.
if( Period() != Saved_Variable_Old_Period ){
Saved_Variable_Old_Period = Period();
Obj_Delete_All();
}
Is this helping you flaab ??
int deinit() { //---- int i, ot=ObjectsTotal()-1; string id; //---- for(i=ot;i>=0;i--) {label=ObjectName(i); if(StringSubstr(label,0,13)=="MyEntryPoints") {ObjectDelete(label); } } return(0); }
flaab:
I would like to detect a timeframe change and clean all objects on the chart from my indicator. Deinit() seems not to execute on a timeframe change on the same chart. -this is, clicking H4 from D1 for example.
if(StringFind(label, "MyEntryPoints")==-1) continue; ObjectDelete(label);
You code looks good and Deinit is executed on a timeframe change.
I suspect your code isn't creating objects with that EXACT pattern. Try:
#define MEP "MyEntryPoints" : ObjectCreate(MEP + ... : if(StringFind(label, MEP) >= 0) ObjectDelete(label);
You code looks good and Deinit is executed on a timeframe change.
I suspect your code isn't creating objects with that EXACT pattern. Try:
why not just use
in the deinit() function?
from post 1 I would like to detect a timeframe change and clean all objects on the chart from my indicator
read it again "from my indicator" not all objects I think
from post 1 I would like to detect a timeframe change and clean all objects on the chart from my indicator
read it again "from my indicator" not all objects I think
You code looks good and Deinit is executed on a timeframe change.
I suspect your code isn't creating objects with that EXACT pattern. Try:
Works flawlessly. Thanks!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello again,
I would like to detect a timeframe change and clean all objects on the chart from my indicator. Deinit() seems not to execute on a timeframe change on the same chart. -this is, clicking H4 from D1 for example.
I would really appreciate some help, and thanks in advance for all your support.