title: Pinescript - for loop with input variable
body: <p>i use tradingview with pinescript 4. I want to insert information on tickers i use (time, buy, sold). When i select a ticker, the script must make a loop to verify if there is variable for this ticker. If the the test is ok, i want to use this variable (buy1 or buy2, sold1 or sold2) on my script by replacing &quot;BuyAlertLevel&quot; and &quot;SellAlertLevel&quot; to draw line.</p>
  <p>The problem is &quot;line 41: Undeclared identifier 'buy'; line 42: Undeclared identifier 'sold'&quot;</p>
  <pre><code>RSIPeriod = input(41, minval=1)
  BuyAlertLevel = input(5, step=1, title=&quot;Buy Alert&quot;)
  SellAlertLevel = input(15, step=1, title=&quot;Sell Alert&quot;)
  RSIHistoModify = input(1.5, step=0.1, title=&quot;RSI Modify&quot;)
  
  tickers1 = input(title=&quot;S&quot;, type=input.string, defval=&quot;PUST&quot;, group = &quot;Suivi des Valeurs&quot;, inline = &quot;1&quot;)
  time1 =input(title=&quot;T&quot;, type=input.integer, defval=120, group = &quot;Suivi des Valeurs&quot;, inline = &quot;1&quot;)
  buy1 =input(defval=0, title=&quot;B&quot;, type=input.integer,  group = &quot;Suivi des Valeurs&quot;, inline = &quot;1&quot;)
  sold1 =input(title=&quot;S&quot;, type=input.integer, defval=15, group = &quot;Suivi des Valeurs&quot;, inline = &quot;1&quot;)
  
  tickers2 = input(title=&quot;S&quot;, type=input.string, defval=&quot;PANX&quot;, group = &quot;Suivi des Valeurs&quot;, inline = &quot;2&quot;)
  time2 =input(title=&quot;T&quot;, type=input.integer, defval=120, group = &quot;Suivi des Valeurs&quot;, inline = &quot;2&quot;)
  buy2 =input(title=&quot;B&quot;, type=input.integer, defval=0,  group = &quot;Suivi des Valeurs&quot;, inline = &quot;2&quot;)
  sold2 =input(title=&quot;S&quot;, type=input.integer, defval=15, group = &quot;Suivi des Valeurs&quot;, inline = &quot;2&quot;)
  
  var tickers = (syminfo.ticker)
  
  for int i = 1 to 2
      if (tickers == tickers[i] and timeframe.multiplier == time[i])
          BuyAlertLevel := buy[i]
          SellAlertLevel := sold[i]
  
  hline(0, &quot;hline&quot; ,color=color.purple, linestyle=hline.style_solid)
  plot(BuyAlertLevel, color=color.green, style=plot.style_line)
  plot(SellAlertLevel, color=color.red, style=plot.style_line)
  </code></pre>
  <p>thanks</p>