The issue is that VWAPs are getting cut off at the new zigzag reversal point. Can you please change the script to make them continuous and not get cut off? I think they need to be cut off at the next zig-zag pivot that is of the same direction and not the opposite.
This extends each of the VWAPs to the last bar
Code:#AnchoredVWAP_using_ZigZag #ZigzagHighLow_Colored_Lines_Limited_Plots #Added up to 5 VWAPs anchored at the zigzag swings ending at the next swing input show_zz_lines = no; input show_vwap_lines = yes; input plot_limited_to_last_x = 5; input priceH = high; input priceL = low; input percentageReversal = 0.05; input absoluteReversal = 0.05; input atrLength = 5; input atrReversal = 2; input tickReversal = 0; def zigzag = ZigZagHighLow("percentage reversal" = percentageReversal, "absolute reversal" = absoluteReversal, "atr length" = atrLength, "atr reversal" = atrReversal, "price h" = priceH, "price l" = priceL).zz; def EIH = ZigZagHighLow("percentage reversal" = percentageReversal, "absolute reversal" = absoluteReversal, "atr length" = atrLength, "atr reversal" = atrReversal, "price h" = priceH, "price l" = priceL).lastH; def EIL = ZigZagHighLow("percentage reversal" = percentageReversal, "absolute reversal" = absoluteReversal, "atr length" = atrLength, "atr reversal" = atrReversal, "price h" = priceH, "price l" = priceL).lastl; #-------------------------- def cond = if !IsNaN(EIH) or !IsNaN(EIL) then 1 else Double.NaN; def dataCount = CompoundValue(1, if !IsNaN(cond) then dataCount[1] + 1 else dataCount[1], 0); def SignalBUY = if HighestAll(dataCount) - dataCount <= plot_limited_to_last_x - 1 then !IsNaN(EIL) else Double.NaN; AddChartBubble(SignalBUY, low, "ZB", Color.WHITE, no); def SignalSELL = if HighestAll(dataCount) - dataCount <= plot_limited_to_last_x - 1 then !IsNaN(EIH) else Double.NaN; AddChartBubble(SignalSELL, high, "ZS", Color.WHITE, yes); def trend = if SignalBUY then 1 else if SignalSELL then -1 else trend[1]; plot zz = if show_zz_lines and HighestAll(dataCount) - dataCount <= plot_limited_to_last_x - 1 then zigzag else Double.NaN; zz.EnableApproximation(); zz.DefineColor("Up", Color.UPTICK); zz.DefineColor("Down", Color.DOWNTICK); zz.SetLineWeight(3); zz.SetStyle(1); zz.HideBubble(); zz.HideTitle(); zz.AssignValueColor(if trend[1] > 0 then zz.Color("Up") else zz.Color("Down")); #Anchored VWAP to ZZ changes def count = if !IsNaN(cond) then count[1] + 1 else count[1]; def ccond = HighestAll(count) - count + 1; def hl = if !IsNaN(EIH) then 1 else if !IsNaN(EIL) then -1 else hl[1]; plot a1 = if !show_vwap_lines or ccond > 1 or plot_limited_to_last_x < 1 then Double.NaN else TotalSum(if ccond <= 1 then (if hl > 0 then priceH else priceL) * (volume) else 0) / TotalSum(if ccond <= 1 then volume else 0); plot a2 = if !show_vwap_lines or ccond > 2 or plot_limited_to_last_x < 2 then Double.NaN else TotalSum(if ccond <= 2 then (if hl > 0 then priceH else priceL) * (volume) else 0) / TotalSum(if ccond <= 2 then volume else 0); plot a3 = if !show_vwap_lines or ccond > 3 or plot_limited_to_last_x < 3 then Double.NaN else TotalSum(if ccond <= 3 then (if hl > 0 then priceH else priceL) * (volume) else 0) / TotalSum(if ccond <= 3 then volume else 0); plot a4 = if !show_vwap_lines or ccond > 4 or plot_limited_to_last_x < 4 then Double.NaN else TotalSum(if ccond <= 4 then (if hl > 0 then priceH else priceL) * (volume) else 0) / TotalSum(if ccond <= 4 then volume else 0); plot a5 = if !show_vwap_lines or ccond > 5 or plot_limited_to_last_x < 5 then Double.NaN else TotalSum(if ccond <= 5 then (if hl > 0 then priceH else priceL) * (volume) else 0) / TotalSum(if ccond <= 5 then volume else 0); a1.SetPaintingStrategy(PaintingStrategy.LINE); a2.SetPaintingStrategy(PaintingStrategy.LINE); a3.SetPaintingStrategy(PaintingStrategy.LINE); a4.SetPaintingStrategy(PaintingStrategy.LINE); a5.SetPaintingStrategy(PaintingStrategy.LINE); a1.SetDefaultColor(Color.WHITE); a2.SetDefaultColor(Color.CYAN); a3.SetDefaultColor(Color.WHITE); a4.SetDefaultColor(Color.YELLOW); a5.SetDefaultColor(Color.WHITE); a1.SetLineWeight(3); a2.SetLineWeight(3); a3.SetLineWeight(3); a4.SetLineWeight(3); a5.SetLineWeight(3); #