Script for opening charts for symbols in the Market watch

 

Hi

I wanted a script to open charts for all the "Unhidden" symbols in the Market watch. With some help, I tried the following code. But it opens all the symbols in the Market watch including the hidden ones. Could someone please help to filter only the "Unhidden (Showing)" symbols in the Market watch?

Thank you

#property script_show_inputs  true
input ENUM_TIMEFRAMES timeFrame = PERIOD_H1;
input string tplName = "1.tpl";       
input uint ptsSpread = 20;                   
int symIndex = 0;
int symSpread = 0;
string symName = "";
long chartID = 0;

void OnStart()
{
   for(symIndex = 0; symIndex < SymbolsTotal(false); symIndex++)
   {
      symName = SymbolName(symIndex, false);
      if(SymbolInfoInteger(symName, SYMBOL_SELECT) == false) SymbolSelect(symName, true);
   }
   Sleep(1000);
   for(symIndex = 0; symIndex < SymbolsTotal(false); symIndex++)
   {
      symName = SymbolName(symIndex, false);
      symSpread = SymbolInfoInteger(symName, SYMBOL_SPREAD);
      if(symSpread > ptsSpread) 
      {
         SymbolSelect(symName, false);
         continue;
      }
      chartID = ChartOpen(symName, timeFrame);
      ChartApplyTemplate(chartID, "//Profiles//Templates//" + tplName);
      ChartSetInteger(chartID, CHART_SHIFT, 0, true);
   }
   

}
 
rhodium1trading:

Hi

I wanted a script to open charts for all the "Unhidden" symbols in the Market watch. With some help, I tried the following code. But it opens all the symbols in the Market watch including the hidden ones. Could someone please help to filter only the "Unhidden (Showing)" symbols in the Market watch?

Thank you

the Selected in symbols total actually is the "in market watch" so you were almost there .

#property script_show_inputs  true
input ENUM_TIMEFRAMES timeFrame = PERIOD_H1;
input string tplName = "1.tpl";       
input uint ptsSpread = 20;                   
int symIndex = 0;
int symSpread = 0;
string symName = "";
long chartID = 0;

void OnStart()
{
   for(symIndex = 0; symIndex < SymbolsTotal(true); symIndex++)
   {
      symName = SymbolName(symIndex, true);
      symSpread = SymbolInfoInteger(symName, SYMBOL_SPREAD);
      if(symSpread > ptsSpread) 
      {
         continue;
      }
      chartID = ChartOpen(symName, timeFrame);
      ChartApplyTemplate(chartID, "//Profiles//Templates//" + tplName);
      ChartSetInteger(chartID, CHART_SHIFT, 0, true);
   }
   

}
 
Lorentzos Roussos #:

the Selected in symbols total actually is the "in market watch" so you were almost there .

Thanks a lot for your swift reply. Cheers!