https://www.mql5.com/en/docs/objects/objectdelete
But you have to know beforehand the Chart ID, AND, the string name of the object to delete it...
;)
- www.mql5.com
Use a prefix so that only and all lines starting with that prefix are removed the function for this is:
Notice it's slightly different than ObjectDelete();Just to add to that
Declared globally and used when naming and drawing objects
string prefix = "My Prefix";
ObjectsDeleteAll(0,Prefix);
will delete all objects with that prefix but only on the same chart that the EA is attached to. The first parameter is 0 which means the current chart.
You will have to figure a way to get the ChartID for the relevant chart.
Thank you very to all of you. May God Bless you all for your generosity to me.
ObjectsDeleteAll(0,OBJ_HLINE) is working...
Yes but that is incorrect use of the Function:
int ObjectsDeleteAll( long chart_id, // chart identifier int sub_window=-1, // window index int type=-1 // object type ); Removes all objects of the specified type using prefix in object names. int ObjectsDeleteAll( long chart_id, // chart ID const string prefix, // prefix in object name int sub_window=-1, // window index int object_type=-1 // object type );
If you want to delete all hlines:
ObjectsDeleteAll(0,-1,OBJ_HLINE);
parameter 1 = chart ID
parameter 2 = window index, 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.
parameter 3 = Object Type
Yes but that is incorrect use of the Function:
If you want to delete all hlines:
parameter 1 = chart ID
parameter 2 = window index, 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.
parameter 3 = Object Type
Objects are usually for the chart instrument only, unless you design an specific interface that is coded to present more data.
The solution is usually elegant and simple.
I am not exactly sure what you are trying to do because you did not post the relevant code.
The solution is usually elegant and simple.
I am not exactly sure what you are trying to do because you did not post the relevant code.
- 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 every one. It is possible that an EA will detect Horizontal Lines on a specific chart and will delete it? Because I am trying to develop an EA that will open a buy position if the price crosses above the horizontal line and will sell if the price crosses below the horizontal line. If the profit is greater than to the target..the EA will close all the open positions and WILL DELETE THE HORIZONTAL LINES in that specific chart.
I tried using the DeleteAll script but it will delete all the object in all the charts that has an objects in it. I hope someone can help me. God Bless you all and Pips be with you always.