MQL4参考 图表操作 ChartOpen


Opens a new chart with the specified symbol and period. The command is added to chart message queue and executed only after all previous commands have been processed.

long  ChartOpen(
   string           symbol,     // Symbol name
   ENUM_TIMEFRAMES  period      // Period



[in]  Chart symbol. NULL means the symbol of the  current chart (the Expert Advisor is attached to).


[in]  Chart period (timeframe). Can be one of the ENUM_TIMEFRAMES values. 0 means the current chart period.

Return Value

If successful, it returns the opened chart ID. Otherwise returns 0. To get error details use the GetLastError() function.


The maximum possible number of simultaneously open charts in the terminal can't exceed the CHARTS_MAX value.