DeleteByName

Download script
Author: ����� �����
DeleteByName

This script is a utility tool designed for the MetaTrader 4 trading platform. Its primary purpose is to automate the cleanup of your trading charts by removing specific visual elements based on a naming rule you define.

How it Works

When you run this script, it performs a systematic scan of every visual object currently present on your active chart. These "objects" can include various types of information such as trend lines, rectangles, text labels, or custom indicators that may have been placed on the screen.

The logic follows these specific steps:

  1. User Input: The script asks you to provide a "Prefix." This is a specific set of characters (for example, a word or a code) that you want to use as a filter.
  2. Full Scan: The tool looks at every single item on your chart, starting from the most recently added one and moving backward until it reaches the beginning.
  3. Matching Logic: For every object it finds, the script checks the very beginning of that object's name.
  4. Selective Removal: If the start of an object's name matches exactly with the prefix you provided, the script automatically deletes that specific object from the chart. If the name does not match your prefix, the object is left completely untouched.

Practical Use Case

This is particularly useful for traders who use automated systems or multiple technical analysis tools. If your indicators or manual drawings are saved with a specific naming convention (e.g., "Trade_Zone_1", "Trade_Zone_2"), you can simply enter "Trade_Zone_" as the prefix. The script will then instantly clear away all those specific zones while leaving other unrelated drawings on your chart exactly where they are.

10 Views
0 Downloads
0 Favorites
DeleteByName
//+------------------------------------------------------------------+
//|                                              DeleteByPreName.mq4 |
//|                                                      Äåíèñ Îðëîâ |
//|                                    http://denis-or-love.narod.ru |
//|Clears the chart of all objects with the name beginning on the specified prefix
//|Äëÿ áûñòðîé î÷èñòêè ãðàôèêà îò îáúåêòîâ ïî íà÷àëó èõ èìåíè        |
//+------------------------------------------------------------------+
#property copyright "Äåíèñ Îðëîâ"
#property link      "http://denis-or-love.narod.ru"


#property show_inputs

extern string PreName ="íàïå÷àòàéòå ïðåôèêñ";
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   for(int k=ObjectsTotal()-1; k>=0; k--)  // Ïî êîëè÷åñòâó âñåõ îáúåêòîâ 
     {
      string Obj_Name=ObjectName(k);   // Çàïðàøèâàåì èìÿ îáúåêòà
      string Head=StringSubstr(Obj_Name,0,StringLen(PreName));// Èçâëåêàåì ïåðâûå ñèì

      if (Head==PreName)// Íàéäåí îáúåêò, ..
         {
         ObjectDelete(Obj_Name);
         //Alert(Head+";"+Prefix);
         }                  
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments