I have created a solution.
#property copyright " " #property link " " #property version "1.00" #property strict input int TIMEFRAME; string charts; long chartid; long Chart_ID; long RemoveChart; //+------------------------------------------------------------------+ int OnInit() { bool TimeFunction=ChartSetSymbolPeriod(chartid,charts,TIMEFRAME); Chart_ID=ChartOpen("EURUSD",TIMEFRAME); RemoveChart=Chart_ID; ChartDesign(); // Chart_ID=ChartOpen("USDMXN",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("GBPUSD",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("GBPUSD",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("AUDUSD",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("GOLD",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("USDCHF",TIMEFRAME); ChartDesign(); Chart_ID=ChartOpen("USDJPY",TIMEFRAME); CloseChart(); ChartDesign(); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ void OnTick() { } //+------------------------------------------------------------------+ void ChartDesign() { ChartSetInteger(Chart_ID,CHART_MODE,CHART_CANDLES); ChartSetInteger(Chart_ID,CHART_SHOW_GRID,false); ChartSetInteger(Chart_ID,CHART_AUTOSCROLL,true); ChartSetInteger(Chart_ID,CHART_SCALE,4); } //+------------------------------------------------------------------+ void CloseChart() { bool CloseAllCharts=ChartClose(RemoveChart); } //+------------------------------------------------------------------+
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone,
I must be missing some steps in trying shutdown some charts currently opened. The code below works with MQL4.
How do I close charts by name or chart ID?