title: Undeclared identifier in Pine loop
body: <p>I have this code:</p>
  
  <pre><code>// Average penetration
  
  high_pen = for i = 0 to penetration_len
  
      penetration = high[i] - shortEma[i]
      sum = high_pen + penetration
      high_pen = penetration &gt; 0 ? sum : 0
      high_pen
  
  average_high_pen = high_pen / penetration_len
  </code></pre>
  
  <p>As you can see, I just want to get all penetration in a bullish trend. The compiler says that <em>high_pen</em> var is not declared in "<em>sum = high_pen + penetration</em>" sentence. It is a very simple loop which it only has to sum the penetration.</p>
  
  <p>How can I do that correctly? How should I declare the  <em>high_pen</em> var and use it after the loop?</p>