= 0.0 loc3 = 0.0 loc4 = 0.0 xx = 0 for x = 1 to 1000 by 1 if hl[x] == ehl and not na(zz[x]) loc1 := zz[x] xx := x + 1 break ehl := hl for x = xx to 1000 by 1 if hl[x] == ehl and not na(zz[x]) loc2 := zz[x] xx := x + 1 break ehl := hl == 1 ? - 1 : 1 for x = xx to 1000 by 1 if hl[x] == ehl and not na(zz[x]) loc3 := zz[x] xx := x + 1 break ehl := hl for x = xx to 1000 by 1 if hl[x] == ehl and not na(zz[x]) loc4 := zz[x] break [loc1, loc2, loc3, loc4] float a = na float b = na float c = na float d = na float e = na if not na(hl) [loc1, loc2, loc3, loc4] = findprevious() a := zz b := loc1 c := loc2 d := loc3 e := loc4 e _hh = zz and a > b and a > c and c > b and c > d _ll = zz and a < b and a < c and c < b and c < d _hl = zz and (a >= c and b > c and b > d and d > c and d > e or a < b and a > c and b < d) _lh = zz and (a <= c and b < c and b < d and d < c and d < e or a > b and a < c and b > d) plotshape(showSwings and _hl, text='HL', title='Higher Low', style=shape.labelup, color=color.new(color.lime, 100), textcolor=colsh, location=location.belowbar, offset=-rb) plotshape(showSwings and _hh, text='HH', title='Higher High', style=shape.labeldown, color=color.new(color.lime, 100), textcolor=colsh, location=location.abovebar, offset=-rb) plotshape(showSwings and _ll, text='LL', title='Lower Low', style=shape.labelup, color=color.new(color.red, 100), textcolor=colsl, location=location.belowbar, offset=-rb) plotshape(showSwings and _lh, text='LH', title='Lower High', style=shape.labeldown, color=color.new(color.red, 100), textcolor=colsl, location=location.abovebar, offset=-rb)