title: How to plot conditionally based on previous plot Pine Script
body: <p>I'm making simple Swing High and Swing Low finder/alert and everything works grate, except there are a lot of cases that Swing High comes after another Swing high.</p>
  
  <p>Logic is simple - a swing high is defined if two candles before have been lower than this one and two candles after are lower as well</p>
  
  <p>What I want to achieve is to plot swing high only if previous plot has not been swing high.</p>
  
  <p>Here will be the code</p>
  
  <pre><code>//@version=4
  study("Swing Point Finder")
  
  hhCondition = high[4] &lt; high[2] and high[3] &lt; high[2] and high[1] &lt; high[2] and high &lt; high[2]
  llCondition = low[4] &gt; low[2] and low[3] &gt; low[2] and low[1] &gt; low[2] and low &gt; low[2]
  
  
  plot(hhCondition ? 1 : 0, "Swing High found", color.green, offset = -2)
  plot(llCondition ? 1 : 0, "Swing Low found", color.red, offset = -2)
  </code></pre>