declare upper; input length = {default “2”, “3”}; input ChartBubblesON = Yes; input LinesON = Yes; plot data; rec top; rec bot; def index; switch (length) { case “2”: index = 2; data= If !ChartBubblesON then Double.NaN else if Low < Low[1] && Low < Low[-1] && Low < Low[2] && Low < Low[-2] then Low else if High > High[1] && High > High[-1] && High > High[2] && High > High[-2] then High else Double.NaN; top = if High > High[1] && High > High[-1] && High > High[2] && High > High[-2] then High else top[1]; bot = if Low < Low[1] && Low < Low[-1] && Low < Low[2] && Low < Low[-2] then Low else bot[1]; case “3”: index = 3; data = If !ChartBubblesON then Double.NaN else if Low < Low[1] && Low < Low[-1] && Low < Low[2] && Low < Low[-2] && Low < Low[3] && Low < Low[-3] then Low else if High > High[1] && High > High[-1] && High > High[2] && High > High[-2] && High > High[3] && High > High[-3] then High else Double.NaN; top = if High > High[1] && High > High[-1] && High > High[2] && High > High[-2] && High > High[3] && High > High[-3] then High else top[1]; bot = if Low < Low[1] && Low < Low[-1] && Low < Low[2] && Low < Low[-2] && Low < Low[3] && Low < Low[-3] then Low else bot[1]; } Data.SetPaintingStrategy(PaintingStrategy.points); Data.SetLineWeight(1); Data.SetDefaultColor(color.yellow); Data.HideBubble(); AddChartBubble(1, Data, concat(“”, data), color.white); plot topline = if !LinesOn then Double.NaN else top; topline.SetLineWeight(1); topline.SetDefaultColor(color.yellow); topline.SetPaintingStrategy(PaintingStrategy.dashes); plot bottomline = if !LinesOn then Double.NaN else bot; bottomline.SetLineWeight(1); bottomline.SetDefaultColor(color.yellow); bottomline.SetPaintingStrategy(PaintingStrategy.dashes); Alert(ChartBubblesON and !IsNaN(data[index]), "Bubble Alert", Alert.BAR, Sound.RING);