title: Writing a for loop in a Pine script
body: <p>I am new to programming.</p>
  
  <p>I wish to write a code in pine script to add range (high-low) for x number of bars back.</p>
  
  <p>Below is part of the code:</p>
  
  <pre><code>//@version=3
  study(title="Vola", overlay = false)
  xnum= input(20)
  
  RangeA= for i = 1 to xnum 
      val_x=high[i]-low[i]
      adding=adding+val_x
  
  
  
  plot(RangeA, color=red, linewidth=2)
  
  error---------------------------------
  line 7: Undeclared identifier `adding`;
  line 11: Undeclared identifier `RangeA`
  </code></pre>