Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ToClearObjectsByType - MetaTrader 5 Script - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

The script deletes from all charts in the client terminal all objects of the type selected by the trader in the input parameters.

 //+--------------------------------------------------------+
//| Script input parameters |
//+--------------------------------------------------------+
Input ENUM_OBJECT object type = - 1 ; //Object type to be deleted

When used with the default parameters, the script will remove all objects from all charts on the client side.

If you frequently need to delete objects of a fixed type, you should script a copy of the object with the appropriate type ID specified as an input variable. For example, here is a script for removing a trendline by clearing the object by OBJ_TREND :

 //+--------------------------------------------------------+
//| Script input parameters |
//+--------------------------------------------------------+
ENUM_OBJECT object type = OBJ_trend ; //Object type to be deleted

Remove the version of the news label that appears periodically and clutters the chart - clear the object via OBJ_EVENT :


Attachment download

📎 toclearobjectsbytype.mq5 (3.32 KB)

📎 toclearobjectsbyobj_trend.mq5 (3.31 KB)

📎 toclearobjectsbyobj_event.mq5 (3.31 KB)

Source: MQL5 #17997

Verification code Refresh