test_objects_list
Download scriptThis script is designed as a utility tool for traders using the MetaTrader platform to organize and audit the visual elements on their trading charts. Its primary purpose is to automatically inventory every visual component currently placed on a specific chart and export that information into an external text file.
How the Logic Works
The script follows a straightforward, three-step process once executed:
1. Identification and File Creation The tool first identifies which financial instrument (e.g., EURUSD, Gold, etc.) you are currently viewing. It then automatically creates a dedicated text file named based on that symbol. This ensures that your data is organized and doesn't get mixed up with other trading pairs.
2. Automated Scanning The script performs a comprehensive scan of the active chart. It looks for every single "object" you have placed there—this includes items such as trendlines, horizontal levels, text labels, rectangles, or custom indicators. Rather than requiring you to click on each one individually, it captures the entire list in a single second.
3. Data Exporting For every object found during the scan, the script extracts three specific pieces of information:
- The Timestamp: The specific time associated with the first point of the object.
- The Name: The unique identifier or name given to that specific drawing.
- The Description: Any additional notes or comments you may have attached to that object.
Finally, it compiles all this data into a clean, comma-separated format within your text file and saves it to your computer.
Why This Is Useful
This tool serves as an "audit" feature. It is particularly helpful for traders who manage complex charts with dozens of different levels and annotations. Instead of manually scrolling through a crowded screen to remember what a specific line represents, you can run this script to generate a clear, readable list of every element on your workspace, making it easier to keep your trading environment organized and professional.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| test_objects_list.mq4 |
//| Copyright © 2006, MQLService |
//| http://www.mqlservice.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MQLService"
#property link "http://www.mqlservice.com"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
// writing the chart objects list to the file
int handle, total;
string obj_name,fname;
// file name
fname="objlist_"+Symbol()+".txt";
handle=FileOpen(fname,FILE_CSV|FILE_WRITE);
if(handle!=false)
{
total=ObjectsTotal();
for(int i=0;i<total;i++)
{
obj_name=ObjectName(i);
FileWrite(handle,TimeToStr(ObjectGet(obj_name, OBJPROP_TIME1))+", "+obj_name+", "+ObjectDescription(obj_name));
}
FileClose(handle);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments