Files
mql5-skills/skills/mql5/references/docs/18-chart-operations/0773-chart-operations-chartfirst.md
T
2026-06-23 21:47:51 +08:00

38 lines
1.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ChartFirst
Returns the ID of the first chart of the client terminal.
```
long  ChartFirst();
```
Return Value
Chart ID.
Example:
```
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- get the ID of the very first chart opened in the client terminal
   long            chart_id= ChartFirst();
   
//--- additionally get the chart symbol and period using the obtained ID
   string          symbol  = ChartSymbol(chart_id);
   ENUM_TIMEFRAMES period  = ChartPeriod(chart_id);
   
//--- display the description of the client terminal first chart in the journal
   PrintFormat("ID of the first chart of the client terminal: %I64d, chart symbol: %s, chart period: %s", chart_id, symbol, StringSubstr(EnumToString(period), 7));
   /*
   result:
   ID of the first chart of the client terminal: 133246248352168440, chart symbol: EURUSD, chart period: M1
   */
  }
```