- ZeroCafeine: but is there another solution to remove any object from the graph just with the mouse without going through the code please?
- Comment is not an object.
- Click to select an object and press delete. If it was created by running code, it may or may not be recreated.
- phade #: this is how can do it:)
Never call that. Code should only delete those objects it creates. When would the Human want the removal of an indicator to remove drawings the Human made? Never.
- Comment is not an object.
- Click to select an object and press delete. If it was created by running code, it may or may not be recreated.
-
Never call that. Code should only delete those objects it creates. When would the Human want the removal of an indicator to remove drawings the Human made? Never.
Ahh very good point. Me personally though - anytime I draw things on the chart, I do so on a separate chart with no indicators (or even on a separate platform). I never really leave drawings there either...I usually draw, maybe grab an image, and then remove my drawings there and then
Comment is not an object.
First of all, thank you for your precise answer. Am I to understand that my solution for deleting a comment is the right one? Or am I missing something again 😊 ?
Never call that. Code should only delete those objects it creates. When would the Human want the removal of an indicator to remove drawings the Human made? Never.
@ZeroCafeine here is a solution that should work for you:
// Loop through all objects on the chart int totalObjects = ObjectsTotal(); for (int i = totalObjects - 1; i >= 0; i--) { string objectName = ObjectName(i); // Check if the object name contains the indicator's name or any other identifier if (StringFind(objectName, "MyIndicatorName") != -1) { // Delete the object ObjectDelete(objectName); } }
tks you phade 😊
1) Let's try to structure our answer. The subject is how to delete a comment 😊, not an object 😉, but we'll try to do both properly,
Can you confirm whether or not I should put this code in the OnDeinit() function? If the answer is yes, then I've already tried and I'm getting errors with the ObjectsTotal() function, I also tried the following settings for the main graph, but they don't work :
int totalObjects = ObjectsTotal(0, 0, -1);
2) Can anyone confirm whether or not I'm doing the right thing by deleting a comment?
void OnDeinit(const int reason) { Comment(""); }
tks you phade 😊
1) Let's try to structure our answer. The subject is how to delete a comment 😊, not an object 😉, but we'll try to do both properly,
Can you confirm whether or not I should put this code in the OnDeinit() function? If the answer is yes, then I've already tried and I'm getting errors with the ObjectsTotal() function, I also tried the following settings for the main graph, but they don't work :
2) Can anyone confirm whether or not I'm doing the right thing by deleting a comment?
this will add empty comments when the indicator is unloaded
Do this instead:
void OnDeinit(const int reason){ // Clear comments from the chart ChartSetString(0, CHART_COMMENT, ""); }
https://www.mql5.com/en/docs/chart_operations/chartsetstring
and this is how you can carefully delete the other things (a working example):
// Loop through all objects on the chart int totalObjects = ObjectsTotal(0); for (int i = totalObjects - 1; i >= 0; i--) { string objectName = ObjectName(0, i); // Check if the object name contains the indicator's name or any other identifier if (StringFind(objectName, "UpArrow") != -1) { // Delete the object ObjectDelete(0, objectName); } else if (StringFind(objectName, "DownArrow") != -1) { // Delete the object ObjectDelete(0, objectName); } else if (StringFind(objectName, "TradeWarningGraphic") != -1) { // Delete the object ObjectDelete(0, objectName); } }
so it can all go in OnDeInit:
void OnDeinit(const int reason){ // ObjectsDeleteAll(0); // Delete all objects on the chart // Loop through all objects on the chart int totalObjects = ObjectsTotal(0); for (int i = totalObjects - 1; i >= 0; i--) { string objectName = ObjectName(0, i); // Check if the object name contains the indicator's name or any other identifier if (StringFind(objectName, "UpArrow") != -1) { // Delete the object ObjectDelete(0, objectName); } else if (StringFind(objectName, "DownArrow") != -1) { // Delete the object ObjectDelete(0, objectName); } else if (StringFind(objectName, "TradeWarningGraphic") != -1) { // Delete the object ObjectDelete(0, objectName); } } // Clear comments from the chart ChartSetString(0, CHART_COMMENT, ""); }
- www.mql5.com
this will add empty comments when the indicator is unloaded
Do this instead:
https://www.mql5.com/en/docs/chart_operations/chartsetstring
The result is exactly the same.
- 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 everyone, I hope you're well.
I'm still a beginner and I'm finding that when I remove an expert advisor then I still see the comments, so I did a quick search and found this solution, so I added an empty comment in the OnDeinit function:
but is there another solution to remove any object from the graph just with the mouse without going through the code please?
Best Reguards,
ZeroCafeine😊