forked from airat77786/MQL5Book
60 lines
2.2 KiB
MQL5
60 lines
2.2 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| ChartList3.mq5 |
| |||
//| Copyright 2021, MetaQuotes Ltd. |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
| |||
#include "..\..\Include\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, *active");
| |||
// keep enumerating all charts until no more found
| |||
while(id != -1)
| |||
{
| |||
temp = 0; // MQL-program counter on every chart
| |||
const string header = StringFormat("%d %lld %s %s %s",
| |||
count, id, ChartSymbol(id), PeriodToString(ChartPeriod(id)),
| |||
(id == me ? "*" : ""));
| |||
| |||
// columns: N, id, symbol, period, self-mark
| |||
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++;
| |||
}
| |||
| |||
count++;
| |||
if(temp > 0)
| |||
{
| |||
used++;
| |||
}
| |||
id = ChartNext(id);
| |||
}
| |||
Print("Total chart number: ", count, ", with MQL-programs: ", used);
| |||
Print("Experts: ", experts, ", Scripts: ", scripts);
| |||
}
| |||
//+------------------------------------------------------------------+
|