The only issue is if the chart window was "minimized". It will appears just the Title bar menu of the chart window. Late I will try to find a function to "maximize".
bool CProgram::ChartChange(constlong id)
{
//--- Check the element IDif(id!=m_table_button.Id())
return(false);
//--- Get a symbolstring symbol=m_symb_trade.GetValue();
if(symbol=="")
symbol=Symbol();
if(!SymbolInfoInteger(symbol,SYMBOL_EXIST))
{
Alert("Check Symbol Name");
return(false);
}
//--- Searching for opened chartsstring chartid[101];
long currChart,prevChart=ChartFirst();
long idchart[101];
int i=0,limit=100;
while(i<limit)// We have certainly not more than 100 open charts
{
idchart[0]=ChartFirst();
chartid[0]=ChartSymbol(idchart[0]);
currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart IDif(currChart<0)
break; // Have reached the end of the chart list
idchart[i+1]=currChart;
chartid[i+1]=ChartSymbol(currChart);
prevChart=currChart;// let's save the current chart ID for the ChartNext()
i++;// Do not forget to increase the counter
}
bool chartexist=false;
long chart_handle;
for(int z=0 ; z<ArraySize(chartid) ; z++)
{
if(chartid[z]==symbol)
{
chartexist=true;
chart_handle=z;
break;
}
}
//--- Open a new chart window
if(!chartexist)
{
Print("Opening new chart window");
if(ChartOpen(symbol,PERIOD_D1)>0)
{
//--- Update the arrays after opened a new chart
while(i<limit)// We have certainly not more than 100 open charts
{
idchart[0]=ChartFirst();
chartid[0]=ChartSymbol(idchart[0]);
currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart IDif(currChart<0)
break; // Have reached the end of the chart list
idchart[i+1]=currChart;
chartid[i+1]=ChartSymbol(currChart);
prevChart=currChart;// let's save the current chart ID for the ChartNext()
i++;// Do not forget to increase the counter
}
}
chartexist=false;
chart_handle;
for(int z=0 ; z<ArraySize(chartid) ; z++)
{
if(chartid[z]==symbol)
{
chartexist=true;
chart_handle=z;
break;
}
}
}
//--- show the chart on top of all otherslong chart_ID=idchart[chart_handle];
if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))
{
//--- display the error message in Experts journalPrint(__FUNCTION__+", Error Code = ",GetLastError());
return(false);
ResetLastError();
}
return(true);
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
There is the part of my code that I used :
It worked fine.
The only issue is if the chart window was "minimized". It will appears just the Title bar menu of the chart window.
Late I will try to find a function to "maximize".
Except there is no WindowHandle on mql5.
Need to use :
And I doubt the rest of the code will work on MT5, but I didn't try.Yeas, you're correct, that was from MQL4. Sorry, I forget which one is being discussed at times.