title: plotting line it is not in accordance with rule
body: <pre><code>depth = input.int(title=&quot;Depth&quot;, defval=2, inline='zzcol')
  tf = input.timeframe(defval = '240', title=&quot;Time Frame&quot;, inline='zzcol')
  bool showzigzag = true
  colUp = input.color(defval=color.green, title='⬆', inline='zzcol')
  colDw = input.color(defval=color.red, title='⬇', inline='zzcol')
  </code></pre>
  <blockquote>
  <pre><code>bool newbar = ta.change(time(tf)) != 0
  i = ta.valuewhen(newbar, bar_index, depth - 1)
  len = bar_index - i + 1
  </code></pre>
  </blockquote>
  <p><em>is there a solution to the problem in this section?</em>&gt;     get_phpl()=&gt;
  *&gt;         float ph = na</p>
  <blockquote>
  <pre><code>    float pl = na
      ph := ta.highestbars(high, nz(len, 1)) == 0 ? high : na
      pl := ta.lowestbars(low, nz(len, 1)) == 0 ? low : na*
  </code></pre>
  </blockquote>
  <pre><code>    [ph, pl]
  
  [ph, pl] = request.security(syminfo.tickerid, tf, get_phpl(), lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_off)
  
  var dir = 0
  iff_1 = pl and na(ph) ? -1 : dir
  dir := ph and na(pl) ? 1 : iff_1
  var max_array_size = 4
  var zigzag = array.new_float(0)
  oldzigzag = array.copy(zigzag)
  
  add_to_zigzag(value, bindex) =&gt;
      array.unshift(zigzag, bindex)
      array.unshift(zigzag, value)
      if array.size(zigzag) &gt; max_array_size
          array.pop(zigzag)
          array.pop(zigzag)
  
  update_zigzag(value, bindex) =&gt;
      if array.size(zigzag) == 0
          add_to_zigzag(value, bindex)
      else
          if dir == 1 and value &gt; array.get(zigzag, 0) or dir == -1 and value &lt; array.get(zigzag, 0)
  array.set(zigzag, 0, value)
  array.set(zigzag, 1, bindex)
          0.
  
  bool dirchanged = dir != dir[1]
  if ph or pl
      if dirchanged
          add_to_zigzag(dir == 1 ? ph : pl, bar_index)
      else
          update_zigzag(dir == 1 ? ph : pl, bar_index)
  
  if showzigzag and array.size(zigzag) &gt;= 4 and array.size(oldzigzag) &gt;= 4
      var line zzline = na
      if array.get(zigzag, 0) != array.get(oldzigzag, 0) or array.get(zigzag, 1) != array.get(oldzigzag, 1)
          if array.get(zigzag, 2) == array.get(oldzigzag, 2) and array.get(zigzag, 3) == math.round(array.get(oldzigzag, 3))
              line.delete(zzline)
          zzline := line.new(x1=math.round(array.get(zigzag, 1)), y1=array.get(zigzag, 0), x2=math.round(array.get(zigzag, 3)), y2=array.get(zigzag, 2), color=dir == 1 ? colUp : colDw, width=1)
          zzline
  
  if not showzigzag and array.size(zigzag) &gt;= 6
      var line zzline = na
      line.delete(zzline)
      zzline := line.new(x1=math.round(array.get(zigzag, 3)), y1=array.get(zigzag, 2), x2=math.round(array.get(zigzag, 5)), y2=array.get(zigzag, 4), color=dir == 1 ? colUp : colDw, style=line.style_solid, width=1)
      zzline
  </code></pre>
  <p><strong>please check this script, so that according to the rules the pivot high or low must be formed from two candles, in the condition in the image the pivot high is formed it should not be because there are no two bars, thank's for help me</strong>
  <a href="https://i.stack.imgur.com/xvOvj.png" rel="nofollow noreferrer">pivot high is formed, for the rule there must be two high bars to form the pivot</a></p>