BDL Range Alert
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © The_Chart_Guru
// @version=5
indicator(title="BDL Range Alert", overlay=true)

// User input
bottomrangeBreakout = input.price(title="Set the Range Low", defval=0.0, confirm=true)
toprangeBreakout = input.price(title="Set Range High", defval=0.0, confirm=true)

// Breakout detection
bottomAlert = bottomrangeBreakout > 0 and close < bottomrangeBreakout
topAlert = toprangeBreakout > 0 and close > toprangeBreakout

// Plots
plot(bottomrangeBreakout > 0 ? bottomrangeBreakout : na, title="Bottom Range Breakout", color=color.rgb(250, 8, 8), offset=9, linewidth=2)
plot(toprangeBreakout > 0 ? toprangeBreakout : na, title="Top Range Breakout", color=color.rgb(4, 250, 13), offset=9, linewidth=2)

// The alerts
alertcondition(bottomAlert, title="Bottom Range Breakout!", message="Bottom breakout for {{ticker}}")
alertcondition(topAlert, title="Top Range Breakout!", message="Top breakout signal for {{ticker}}")
alertcondition(topAlert or bottomAlert, title="Range Breakout!", message="Breakout signal for {{ticker}}")