#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link ""
#property version "1.00"
/+------------------------------------------------------------------+
//| Script program start function |
/+------------------------------------------------------------------+
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 sub_wnd=0; sub_wnd<(int)wnd; sub_wnd++)
{
//--- 저널에 차트 헤더를 표시합니다.
string wnd_name=(sub_wnd==0 ? "Main window:" : StringFormat("Subwindow %d:", sub_wnd));
Print(wnd_name);
//--- 현재 하위 창에 있는 그래픽 객체의 수를 가져옵니다.
//--- 그리고 모든 하위 창 객체를 통한 루프에서 각각의 이름을 출력합니다.
int objects=ObjectsTotal(chart_id, sub_wnd);
for(int obj_index=0; obj_index<objects; obj_index++)
{
//--- 루프 내의 현재 객체 이름
string obj_name=ObjectName(chart_id, obj_index, sub_wnd);
//--- 이것이 거래 라벨(자동 거래)인 경우 이 객체의 이름은 저널에 표시되지 않습니다.
if(sub_wnd==0 && StringFind(obj_name, "autotrade")==0)
continue;
PrintFormat(" [%d] Graphic object name: \"%s\"", obj_index, obj_name);
}
}
/*
두 개의 하위 창이 있는 메인 창에 대한 결과
메인 창에는 두 개의 그래픽 객체와 거래 레이블(건너뜀)이 포함되어 있습니다.
각 차트 하위 창에는 두 개의 그래픽 객체가 구성됩니다.
Main window:
[0] Graphic object name: "M30 Fibo 29182"
[1] Graphic object name: "M30 Vertical Line 13600"
Subwindow 1:
[0] Graphic object name: "M30 Cycle Lines 63004"
[1] Graphic object name: "M30 Trendline 40731"
Subwindow 2:
[0] Graphic object name: "M30 Equidistant Channel 58930"
[1] Graphic object name: "M30 Rectangle 5636"
*/
}
|