The indicator must be separated into 2 different codes. One that plot the previous zigzag points and segments and another one that plot the actual price difference since the last point, here are the 2 codes below:
Apply them on your price chart.
zzpoint=30
zzh=ZigZagPoint[zzpoint](high)
zzl=ZigZagPoint[zzpoint](low)
if zzh<zzh[1] and zzh[1]>zzh[2] then
hh=zzh[1]
hhbar=barindex[1]
diff=hh-ll
drawtext("#diff#",hhbar,hh,dialog,bold,30)coloured(0,191,255)
drawsegment(hhbar,hh,llbar,ll)coloured(0,191,255)
endif
if zzl>zzl[1] and zzl[1]<zzl[2] then
ll=zzl[1]
llbar=barindex[1]
diff=hh-ll
drawtext("#diff#",llbar,ll,dialog,bold,30)coloured(0,191,255)
drawsegment(hhbar,hh,llbar,ll)coloured(0,191,255)
endif
return
plot the points differences:
defparam drawonlastbaronly=true
zzpoint=30
zzh=ZigZagPoint[zzpoint](high)
zzl=ZigZagPoint[zzpoint](low)
if zzh<zzh[1] and zzh[1]>zzh[2] then
last=zzh[1]
endif
if zzl>zzl[1] and zzl[1]<zzl[2] then
last=zzl[1]
endif
diff=abs(close-last)
drawtext("#diff#",barindex,high+AverageTrueRange[14](close),dialog,bold,30)coloured(0,191,255)
return
Because of the repainting nature of zigzag, the last segments could retrace itself repeatedly over time, so you’ll have to reload the chart once in a while.