chart open and close

 
Hi,  I have an expert which opens (for example every 1 min.) charts of some symbols that may have potential for trade, when I trade some of them I need to close the other charts except those which I trade on them. So how can I have open only charts that have position on them? thank you in advance.
void OnTick()
  {
   if(is_new_candle(PERIOD_M1))
     {
     cose_all_charts_except_expert();
      for(int j=0; j<3; j++)
        {
         for(int i=0; i<=SymbolsTotal(false)-1; i++)
           {
            string symbol=SymbolName(i,false);
            long spread=SymbolInfoInteger(symbol,SYMBOL_SPREAD);
            if(spread>10 && spread<30 &&(hammer_checker(symbol,priod[j])==1 ||hammer_checker(symbol,priod[j])==-1))
              {
               SymbolSelect(symbol,true);
               Comment(symbol,"\n",EnumToString(priod[j]),"\n");//,"i= ",i);
           //               close_all_charts_except_expert();
               Sleep(800);
               //if(ChartOpen(symbol,priod[j])==NULL)
                 {
                  ChartOpen(symbol,priod[j]);
                  Print(symbol,"-",EnumToString(priod[j]));
                 }
              }
           }
        }
     }
  }
.
 
337252: . So how can I have open only charts that have position on them? thank you in advance. .

How do you think. Create a list of symbols from your list of charts. Remove the symbols from your list of open positions. Close whatever is left.