Download MetaTrader 5
MQL5 ReferenceChart OperationsChartSetSymbolPeriod 


Changes the symbol and period of the specified chart. The function is asynchronous, i.e. it sends the command and does not wait for its execution completion. The command is added to chart messages queue and will be executed after processing of all previous commands.

bool  ChartSetSymbolPeriod(
   long             chart_id,     // Chart ID
   string           symbol,       // Symbol name
   ENUM_TIMEFRAMES  period        // Period



[in]  Chart ID. 0 means the current chart.


[in]  Chart symbol. NULL value means the current chart symbol (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

Returns true if the command has been added to chart queue, otherwise false. To get an information about the error, call the GetLastError() function.


The symbol/period change leads to the re-initialization of the Expert Advisor attached to a chart.

The call of ChartSetSymbolPerid with the same symbol and timeframe can be used to update the chart (similar to the terminal's Refresh command). In its turn, the chart update triggers re-calculation of the indicators attached to it. Thus, you are able to calculate an indicator on the chart even if there are no ticks (e.g., on weekends).

See also

ChartSymbol, ChartPeriod

Updated: 2016.11.29