Download MetaTrader 5

Mql5 - ChartSetSymbolPeriod - Crashes the chart window

To add comments, please log in or register
gr101 2016.04.16 22:47 


I'm testing the ChartSetSymbolPeriod method in mql5 however it seems to be crashing my chart window.


  1. Open MetaTrader and open a "AUDCAD" chart so that it's the only chart open.
  2. Open MetaEditor
  3. Create a new script
  4. In the OnStart() method I put the following line of code: ChartSetSymbolPeriod(0, "EURUSD", PERIOD_H1);
  5. Run the script
  6. It gets to the line of code above and then the debug chart window closes and the script does not continue (it stops)

Any ideas what I'm doing wrong or what the issue is?


void OnStart()
   ChartSetSymbolPeriod(0, "EURUSD", PERIOD_H1);  

System info:

MetaTrader/MetaEditor version: 5.00 build 1241 22 Dec 2015

Operating system: Windows 8.1 Enterprise


Marco vd Heijden
Marco vd Heijden 2016.04.16 22:52  


The symbol/period change leads to the re-initialization of the Expert Advisor, attached to a chart. Re-initialization is not performed on offline charts, they're only refreshed (the same as when clicking Refresh in the terminal).

Note 2

Scripts run once they do not re-initialize it is therefore impossible to change the chart symbol period and then add a comment (to the new chart).

Possible solution: convert to Expert advisor.

To add comments, please log in or register