Sma aliGOLD (US$/OZ)TVC:GOLDali_aj5//@version=6 indicator("Ali SMC - BOS & CHoCH", overlay=true, max_labels_count=500) swing = input.int(5, "Swing Length", minval=2) ph = ta.pivothigh(high, swing, swing) pl = ta.pivotlow(low, swing, swing) var float lastHigh = na var float lastLow = na var int trend = 0 if not na(ph) lastHigh := ph if not na(pl) lastLow := pl bullBos = not na(lastHigh) and close > lastHigh bearBos = not na(lastLow) and close < lastLow bullChoch = bullBos and trend == -1 bearChoch = bearBos and trend == 1 if bullBos trend := 1 if bearBos trend := -1 plotshape(bullBos and not bullChoch, title="Bull BOS", text="BOS", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white) plotshape(bearBos and not bearChoch, title="Bear BOS", text="BOS", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white) plotshape(bullChoch, title="Bull CHoCH", text="CHoCH", style=shape.labelup, location=location.belowbar, color=color.blue, textcolor=color.white) plotshape(bearChoch, title="Bear CHoCH", text="CHoCH", style=shape.labeldown, location=location.abovebar, color=color.orange, textcolor=color.white) alertcondition(bullBos, title="Bull BOS", message="Bullish BOS") alertcondition(bearBos, title="Bear BOS", message="Bearish BOS") alertcondition(bullChoch, title="Bull CHoCH", message="Bullish CHoCH") alertcondition(bearChoch, title="Bear CHoCH", message="Bearish CHoCH")