title: Pine Script - How to calculate an average value of the last 5 pivots?
body: <p>I want to calculate the average value of the previous pivots, but the problem is, that when I use something like </p>
  
  <pre><code>plot(pivothigh(close, 14, 14)[2]) + plot(pivothigh(close, 14, 14)[3]) / 2 
  </code></pre>
  
  <p>and then plot the result, it sliding down like if I would just use "highest". 
  What I'm trying to do, is calculate the average, and to do so I need to access the exact value of the previous pivots. Can someone help me with that? I'm fighting with it 3 days in a row and when I think it works, I calculating stuff manually and it appears that something is wrong. </p>
  
  <p>Thank you in advance! </p>