OPEN-SOURCE SCRIPT

Breakout Point Highlighting

417
//version=6
indicator("Breakout Point Highlighting", overlay=true)

// Input: Lookback period for finding breakout points
lookbackPeriod = input.int(20, title="Lookback Period", minval=1)

// Calculate the highest high and lowest low over the lookback period
highestHigh = ta.highest(high, lookbackPeriod)
lowestLow = ta.lowest(low, lookbackPeriod)

// Breakout conditions: price breaks above the highest high or below the lowest low
breakoutUp = close > highestHigh
breakoutDown = close < lowestLow

// Plot the breakout points
plotshape(breakoutUp, color=color.green, style=shape.triangleup, location=location.belowbar, title="Breakout Up", size=size.small)
plotshape(breakoutDown, color=color.red, style=shape.triangledown, location=location.abovebar, title="Breakout Down", size=size.small)

// Highlight the breakout zones
bgcolor(breakoutUp ? color.new(color.green, 90) : na, title="Breakout Up Highlight")
bgcolor(breakoutDown ? color.new(color.red, 90) : na, title="Breakout Down Highlight")

// Alert conditions
alertcondition(breakoutUp, title="Breakout Up Alert", message="Price has broken above the highest high.")
alertcondition(breakoutDown, title="Breakout Down Alert", message="Price has broken below the lowest low.")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.