#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link ""
#property version "1.00"
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 图表 ID
long chart_id=ChartID();
//---获取图表子窗口包括主窗口的数量
long wnd=0;
ResetLastError();
if(!ChartGetInteger(chart_id, CHART_WINDOWS_TOTAL, 0, wnd))
{
Print("ChartGetInteger() failed. Error ", GetLastError());
return;
}
//--- 获取并在日志中显示每个子窗口中图形对象的数量
for(int i=0; i<(int)wnd; i++)
{
int objects=ObjectsTotal(chart_id, i);
string wnd_head=(i==0 ? "The main chart window" : StringFormat("The window with index %d of the chart", i));
PrintFormat("%s contains %d graphic objects", wnd_head, objects);
}
/*
具有两个子窗口的主窗口的结果,
其中主窗口包含交易标签,
而子窗口中有两个图形对象:
The main chart window contains 656 graphic objects
The window with index 1 of the chart contains 2 graphic objects
The window with index 2 of the chart contains 2 graphic objects
*/
}
|