0

I want to write a code about Zig Zag by connect pivot highs and lows.In common cases it shall be high to low connection.Some is low to low twice.But I found it show high to high several times and missing lows.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © david03kimo

//@version=4
maxbarsback=500
study("Zig Zag by David",overlay=true,max_bars_back=maxbarsback)

pH=0.0
pL=0.0
pH := pivothigh(2,2)
pL := pivotlow(2,2)
var line l=na
var label p=na

if not(na(pH)) or not(na(pL))
    x1=0
    y1=high
    x2=0
    y2=low
    x2:=bar_index - 2
    y2:=not(na(pH))?pH:pL
    x1:=x2[1]
    y1:=y2[1]
    l:=line.new(x1,y1,x2,y2,extend=extend.none,color=color.white)
    p:=label.new(x2,y2==pL?pL:na,style=label.style_triangledown)
line.delete(l[100])
label.delete(p[100])

enter image description here

David Liao
  • 61
  • 1
  • 7
  • Can you state your objective more clearly please. Where do you want lines? Between all pivots found? If not, explain your conditions pls. – PineCoders-LucF Apr 14 '20 at 04:16
  • Sorry,my bad.I found it is possible.The objective is to connect the pivot highs and lows as a Elliott wave. – David Liao Apr 22 '20 at 04:16

0 Answers0