Checking for Alert - then closing window if no Alert

 

Hi all, so I have a piece of code that loops through all the instruments - alerts trigger as required in my Alerts box correctly.

I then am closing all the windows after this as a tidy up.

Currently I am going through the alerts manually in the alerts window to check which instruments alerted and then re-opening them to check it out.


1.  Is there a way of conditionally checking {if 'Alert occured'} do NOT chartclose

2.  Is there a way of clearing the Alert window pop up programmatically?


Current Code here:


void OnStart(){

   for(int i=0;i<SymbolsTotal(false);i++){

      if(   StringFind(SymbolName(i,false),".r",0)!=-1 

            ){

         ChartOpen(SymbolName(i,false),TimeFrame);

      }

   }

   

   //Closing all chart which are not the current chart

   long currChart,prevChart=ChartFirst(); 

   int z=0,limit=100; 

   ChartClose(prevChart);

   while(z<limit)// We have certainly not more than 100 open charts 

     { 

      currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID 

      if(currChart<0) break;          // Have reached the end of the chart list 

      if(prevChart!=ChartID()) ChartClose(prevChart); // Close the chart which is not current chart

      prevChart=currChart;// let's save the current chart ID for the ChartNext() 

      z++;// Do not forget to increase the counter 

     }

   

}
Documentation on MQL5: Chart Operations / ChartOpen
Documentation on MQL5: Chart Operations / ChartOpen
  • www.mql5.com
Chart Operations / ChartOpen - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: