//version=5
indicator("Buy/Sell Signal with Alerts", overlay=true)
// Define input parameters
fastLength = input.int(9, title="Fast MA Length")
slowLength = input.int(21, title="Slow MA Length")
// Calculate moving averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Generate buy/sell signals
buySignal = ta.crossover(fastMA, slowMA)
sellSignal = ta.crossunder(fastMA, slowMA)
// Plot buy/sell signals
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
// Send alerts
alertcondition(buySignal, title="Buy Signal", message="Buy Signal Detected")
alertcondition(sellSignal, title="Sell Signal", message="Sell Signal Detected")
indicator("Buy/Sell Signal with Alerts", overlay=true)
// Define input parameters
fastLength = input.int(9, title="Fast MA Length")
slowLength = input.int(21, title="Slow MA Length")
// Calculate moving averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Generate buy/sell signals
buySignal = ta.crossover(fastMA, slowMA)
sellSignal = ta.crossunder(fastMA, slowMA)
// Plot buy/sell signals
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
// Send alerts
alertcondition(buySignal, title="Buy Signal", message="Buy Signal Detected")
alertcondition(sellSignal, title="Sell Signal", message="Sell Signal Detected")
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.
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.