title: Pine Script for loop
body: <p>I'm trying to make a script where TradingView shows a label with all the results of the code. I really want a loop to get the code to catch all the data of multiple tickers (Heikin-Ashi charts). The code below doesn't work properly.</p>
  <p>So, for every ticker, the loop needs to check if result = true; if so, then it needs the ticker to be added to the label:</p>
  <pre><code>s20ema = ema(close, 20)
  s50sma = sma(close, 50)
  s200sma = sma(close, 200)
  
  scr_label = 'Screener: \n##########\n'
  
  ticker_s1 = 'ADAUSDT'
  ticker_s2 = 'ADXBTC'
  ticker_s3 = 'AEBTC'
  ticker_s4 = 'AGIBTC'
  ticker_s5 = 'AIONBTC'
  
  ha_period = &quot;W&quot; // Chart on which Master Direction is based
  ha_open = security(heikinashi(ticker_s1), ha_period, open)
  ha_close = security(heikinashi(ticker_s1), ha_period, close)
  
  customFuncW() =&gt; (s20ema &gt; s50sma) and (s50sma &gt; s200sma) and (ha_close &lt; ha_open)
  
  s1  = security(ticker_s1,  'W', customFuncW())
  s2  = security('ADXBTC',  'W', customFuncW())
  s3  = security('AEBTC',  'W', customFuncW())
  s4  = security('AGIBTC',  'W', customFuncW())
  s5  = security('AIONBTC',  'W', customFuncW())
  
  s = 1
  for i = 0 to 5 
      s := s + 1
      scr_label := s[i] ? scr_label + ticker_s[i] + '\n' : scr_label  
  
  lab_l = label.new(
      bar_index, -0.2, scr_label, 
      color=color.gray, 
      textcolor=color.black, 
      style =  label.style_labeldown,
      yloc = yloc.price)
  
  label.delete(lab_l[1])
  
  plot(0, transp = 100)
  </code></pre>
  <p>This code gives me an &quot;undeclarer identifier 'ticker_s' &quot; (the one in the for loop). Anybody has an idea?!</p>