title: I want to write a code for a buy condition: closing price has been rising for the last 5 bars
body: <p>Let's say my strategy is to buy a stock that has been rising for the past 5 bars.</p>
  <p>I would write something like this:</p>
  <p><code>longCondition = (close &gt; close[1]) and (close[1] &gt; close[2]) and (close[2] &gt; close[3]) and (close[3] &gt; close[4]) and (close[4] &gt; close[5])</code></p>
  <p>However, I have a feeling that there's a simpler way to code this by using a variable that updates itself. I'm not so sure though. How could I improve this?</p>