-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChartList4.mq5
73 lines (65 loc) · 2.76 KB
/
ChartList4.mq5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//+------------------------------------------------------------------+
//| ChartList4.mq5 |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include <MQL5Book/Periods.mqh>
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
ChartList();
}
//+------------------------------------------------------------------+
//| Main worker function to enumerate charts |
//+------------------------------------------------------------------+
void ChartList()
{
const long me = ChartID();
long id = ChartFirst();
int count = 0, used = 0, temp, experts = 0, scripts = 0;
Print("Chart List\nN, ID, Symbol, TF, #subwindows, *active, Windows handle");
// keep enumerating all charts until no more found
while(id != -1)
{
temp = 0; // MQL-program counter on every chart
const int win = (int)ChartGetInteger(id, CHART_WINDOWS_TOTAL);
const string header = StringFormat("%d %lld %s %s %s %s %s %s %lld",
count, id, ChartSymbol(id), PeriodToString(ChartPeriod(id)),
(win > 1 ? "#" + (string)(win - 1) : ""), (id == me ? "*" : ""),
(ChartGetInteger(id, CHART_BRING_TO_TOP, 0) ? "active" : ""),
(ChartGetInteger(id, CHART_IS_OBJECT) ? "object" : ""),
ChartGetInteger(id, CHART_WINDOW_HANDLE));
// columns: N, id, symbol, period, subwindow #number, self-mark, active status, object type, handle
Print(header);
string expert = ChartGetString(id, CHART_EXPERT_NAME);
string script = ChartGetString(id, CHART_SCRIPT_NAME);
if(StringLen(expert) > 0) expert = "[E] " + expert;
if(StringLen(script) > 0) script = "[S] " + script;
if(expert != NULL || script != NULL)
{
Print(expert, " ", script);
if(expert != NULL) experts++;
if(script != NULL) scripts++;
temp++;
}
for(int i = 0; i < win; i++)
{
const bool visible = ChartGetInteger(id, CHART_WINDOW_IS_VISIBLE, i);
if(!visible)
{
Print(" ", i, "/Hidden");
}
}
count++;
if(temp > 0)
{
used++;
}
id = ChartNext(id);
}
Print("Total chart number: ", count, ", with MQL-programs: ", used);
Print("Experts: ", experts, ", Scripts: ", scripts);
}
//+------------------------------------------------------------------+