OPEN-SOURCE SCRIPT
Stocks Multi-Indicator Alerts (cryptodaddy)

//version=6
// Multi-Indicator Alerts
// --------------------------------------------
// This script combines technical indicators and basic analyst data
// to produce composite buy and sell signals. Each block is heavily
// commented so future modifications are straightforward.
indicator("Multi-Indicator Alerts", overlay=true, max_labels_count=500)
//// === Daily momentum indicators ===
// Relative Strength Index measures price momentum.
rsiLength = input.int(14, "RSI Length")
rsi = ta.rsi(close, rsiLength)
// Money Flow Index incorporates volume to track capital movement.
// In Pine Script v6 the function only requires a price source and length;
// volume is taken from the built-in `volume` series automatically.
mfLength = input.int(14, "Money Flow Length")
mf = ta.mfi(hlc3, mfLength)
// `mfUp`/`mfDown` flag a turn in money flow over the last two bars.
mfUp = ta.rising(mf, 2)
mfDown = ta.falling(mf, 2)
//// === WaveTrend oscillator ===
// A simplified WaveTrend model produces "dots" indicating potential
// exhaustion points. Values beyond +/-53 are treated as oversold/overbought.
n1 = input.int(10, "WT Channel Length")
n2 = input.int(21, "WT Average Length")
ap = hlc3 // typical price
esa = ta.ema(ap, n1) // smoothed price
d = ta.ema(math.abs(ap - esa), n1) // smoothed deviation
ci = (ap - esa) / (0.015 * d) // channel index
tci = ta.ema(ci, n2) // trend channel index
wt1 = tci // main line
wt2 = ta.sma(wt1, 4) // signal line
greenDot = ta.crossover(wt1, wt2) and wt1 < -53
redDot = ta.crossunder(wt1, wt2) and wt1 > 53
plotshape(greenDot, title="Green Dot", style=shape.circle, color=color.green, location=location.belowbar, size=size.tiny)
plotshape(redDot, title="Red Dot", style=shape.circle, color=color.red, location=location.abovebar, size=size.tiny)
//// === Analyst fundamentals ===
// Fundamental values from TradingView's database. If a ticker lacks data
// these will return `na` and the related conditions simply evaluate false.
rating = request.financial(syminfo.tickerid, "rating", period="FY")
targetHigh = request.financial(syminfo.tickerid, "target_high_price", period="FY")
targetLow = request.financial(syminfo.tickerid, "target_low_price", period="FY")
upsidePct = (targetHigh - close) / close * 100
downsidePct = (close - targetLow) / close * 100
// `rating` comes back as a numeric value (1 strong sell -> 5 strong buy). Use
// thresholds instead of string comparisons so the script compiles even when
// the broker only supplies numeric ratings.
ratingBuy = rating >= 4 // buy or strong buy
ratingNeutralOrBuy = rating >= 3 // neutral or better
upsideCondition = upsidePct >= 2 * downsidePct // upside at least twice downside
downsideCondition = downsidePct >= upsidePct // downside greater or equal
//// === Daily moving-average context ===
// 50 EMA represents short-term trend; 200 EMA long-term bias.
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
longBias = close > ema200 // price above 200-day = long bias
momentumFavorable = close > ema50 // price above 50-day = positive momentum
//// === Weekly trend filter ===
// Higher timeframe confirmation to reduce noise.
weeklyClose = request.security(syminfo.tickerid, "W", close)
weeklyEMA20 = request.security(syminfo.tickerid, "W", ta.ema(close, 20))
weeklyRSI = request.security(syminfo.tickerid, "W", ta.rsi(close, rsiLength))
// Weekly Money Flow uses the same two-argument `ta.mfi()` inside `request.security`.
weeklyMF = request.security(syminfo.tickerid, "W", ta.mfi(hlc3, mfLength))
weeklyFilter = weeklyClose > weeklyEMA20
//// === Buy evaluation ===
// Each true condition contributes one point to `buyScore`.
c1_buy = rsi < 50 // RSI below midpoint
c2_buy = mfUp // Money Flow turning up
c3_buy = greenDot // WaveTrend oversold bounce
c4_buy = ratingBuy // Analyst rating Buy/Strong Buy
c5_buy = upsideCondition // Forecast upside twice downside
buyScore = (c1_buy?1:0) + (c2_buy?1:0) + (c3_buy?1:0) + (c4_buy?1:0) + (c5_buy?1:0)
// Require all five conditions plus trend filters and persistence for two bars.
buyCond = c1_buy and c2_buy and c3_buy and c4_buy and c5_buy and longBias and momentumFavorable and weeklyFilter and weeklyRSI > 50 and weeklyMF > 50
buySignal = buyCond and buyCond[1]
//// === Sell evaluation ===
// Similar logic as buy side but inverted.
c1_sell = rsi > 70 // RSI above overbought threshold
c2_sell = mfDown // Money Flow turning down
c3_sell = redDot // WaveTrend overbought reversal
c4_sell = ratingNeutralOrBuy // Analysts neutral or still buy
c5_sell = downsideCondition // Downside at least equal to upside
sellScore = (c1_sell?1:0) + (c2_sell?1:0) + (c3_sell?1:0) + (c4_sell?1:0) + (c5_sell?1:0)
// For exits require weekly filters to fail or long bias lost.
sellCond = c1_sell and c2_sell and c3_sell and c4_sell and c5_sell and (not longBias or not weeklyFilter or weeklyRSI < 50)
sellSignal = sellCond and sellCond[1]
// Plot composite scores for quick reference.
plot(buyScore, "Buy Score", color=color.green)
plot(sellScore, "Sell Score", color=color.red)
//// === Confidence table ===
// Shows which of the five buy/sell checks are currently met.
var table status = table.new(position.top_right, 5, 2, border_width=1)
if barstate.islast
table.cell(status, 0, 0, "RSI", bgcolor=c1_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 1, 0, "MF", bgcolor=c2_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 2, 0, "Dot", bgcolor=c3_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 3, 0, "Rating", bgcolor=c4_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 4, 0, "Target", bgcolor=c5_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 0, 1, "RSI>70", bgcolor=c1_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 1, 1, "MF down",bgcolor=c2_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 2, 1, "Red dot", bgcolor=c3_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 3, 1, "Rating", bgcolor=c4_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 4, 1, "Target", bgcolor=c5_sell?color.new(color.red,0):color.new(color.green,0))
//// === Alert text ===
// Include key metrics in alerts so the chart doesn't need to be opened.
buyMsg = "BUY: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
sellMsg = "SELL: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
// Alert conditions use static messages; dynamic data is sent via `alert()`
alertcondition(buySignal, title="Buy Signal", message="Buy conditions met")
alertcondition(sellSignal, title="Sell Signal", message="Sell conditions met")
if buySignal
alert(buyMsg, alert.freq_once_per_bar_close)
if sellSignal
alert(sellMsg, alert.freq_once_per_bar_close)
//// === Watch-out flags ===
// Gentle warnings when trends weaken but before full sell signals.
warnRSI = rsi > 65 and rsi[1] <= 65
warnAnalyst = upsidePct < 2 * downsidePct and upsidePct > downsidePct
alertcondition(warnRSI, title="RSI Watch", message="RSI creeping above 65")
alertcondition(warnAnalyst, title="Analyst Watch", message="Analyst upside shrinking")
if warnRSI
alert("RSI creeping above 65: " + str.tostring(rsi, "#.##"), alert.freq_once_per_bar_close)
if warnAnalyst
alert("Analyst upside shrinking: up " + str.tostring(upsidePct, "#.##") + "% vs down " + str.tostring(downsidePct, "#.##") + "%", alert.freq_once_per_bar_close)
//// === Plot bias moving averages ===
plot(ema50, color=color.orange, title="EMA50")
plot(ema200, color=color.blue, title="EMA200")
//// === Cross alerts for context ===
goldenCross = ta.crossover(ema50, ema200)
deathCross = ta.crossunder(ema50, ema200)
alertcondition(goldenCross, title="Golden Cross", message="50 EMA crossed above 200 EMA")
alertcondition(deathCross, title="Death Cross", message="50 EMA crossed below 200 EMA")
// Multi-Indicator Alerts
// --------------------------------------------
// This script combines technical indicators and basic analyst data
// to produce composite buy and sell signals. Each block is heavily
// commented so future modifications are straightforward.
indicator("Multi-Indicator Alerts", overlay=true, max_labels_count=500)
//// === Daily momentum indicators ===
// Relative Strength Index measures price momentum.
rsiLength = input.int(14, "RSI Length")
rsi = ta.rsi(close, rsiLength)
// Money Flow Index incorporates volume to track capital movement.
// In Pine Script v6 the function only requires a price source and length;
// volume is taken from the built-in `volume` series automatically.
mfLength = input.int(14, "Money Flow Length")
mf = ta.mfi(hlc3, mfLength)
// `mfUp`/`mfDown` flag a turn in money flow over the last two bars.
mfUp = ta.rising(mf, 2)
mfDown = ta.falling(mf, 2)
//// === WaveTrend oscillator ===
// A simplified WaveTrend model produces "dots" indicating potential
// exhaustion points. Values beyond +/-53 are treated as oversold/overbought.
n1 = input.int(10, "WT Channel Length")
n2 = input.int(21, "WT Average Length")
ap = hlc3 // typical price
esa = ta.ema(ap, n1) // smoothed price
d = ta.ema(math.abs(ap - esa), n1) // smoothed deviation
ci = (ap - esa) / (0.015 * d) // channel index
tci = ta.ema(ci, n2) // trend channel index
wt1 = tci // main line
wt2 = ta.sma(wt1, 4) // signal line
greenDot = ta.crossover(wt1, wt2) and wt1 < -53
redDot = ta.crossunder(wt1, wt2) and wt1 > 53
plotshape(greenDot, title="Green Dot", style=shape.circle, color=color.green, location=location.belowbar, size=size.tiny)
plotshape(redDot, title="Red Dot", style=shape.circle, color=color.red, location=location.abovebar, size=size.tiny)
//// === Analyst fundamentals ===
// Fundamental values from TradingView's database. If a ticker lacks data
// these will return `na` and the related conditions simply evaluate false.
rating = request.financial(syminfo.tickerid, "rating", period="FY")
targetHigh = request.financial(syminfo.tickerid, "target_high_price", period="FY")
targetLow = request.financial(syminfo.tickerid, "target_low_price", period="FY")
upsidePct = (targetHigh - close) / close * 100
downsidePct = (close - targetLow) / close * 100
// `rating` comes back as a numeric value (1 strong sell -> 5 strong buy). Use
// thresholds instead of string comparisons so the script compiles even when
// the broker only supplies numeric ratings.
ratingBuy = rating >= 4 // buy or strong buy
ratingNeutralOrBuy = rating >= 3 // neutral or better
upsideCondition = upsidePct >= 2 * downsidePct // upside at least twice downside
downsideCondition = downsidePct >= upsidePct // downside greater or equal
//// === Daily moving-average context ===
// 50 EMA represents short-term trend; 200 EMA long-term bias.
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
longBias = close > ema200 // price above 200-day = long bias
momentumFavorable = close > ema50 // price above 50-day = positive momentum
//// === Weekly trend filter ===
// Higher timeframe confirmation to reduce noise.
weeklyClose = request.security(syminfo.tickerid, "W", close)
weeklyEMA20 = request.security(syminfo.tickerid, "W", ta.ema(close, 20))
weeklyRSI = request.security(syminfo.tickerid, "W", ta.rsi(close, rsiLength))
// Weekly Money Flow uses the same two-argument `ta.mfi()` inside `request.security`.
weeklyMF = request.security(syminfo.tickerid, "W", ta.mfi(hlc3, mfLength))
weeklyFilter = weeklyClose > weeklyEMA20
//// === Buy evaluation ===
// Each true condition contributes one point to `buyScore`.
c1_buy = rsi < 50 // RSI below midpoint
c2_buy = mfUp // Money Flow turning up
c3_buy = greenDot // WaveTrend oversold bounce
c4_buy = ratingBuy // Analyst rating Buy/Strong Buy
c5_buy = upsideCondition // Forecast upside twice downside
buyScore = (c1_buy?1:0) + (c2_buy?1:0) + (c3_buy?1:0) + (c4_buy?1:0) + (c5_buy?1:0)
// Require all five conditions plus trend filters and persistence for two bars.
buyCond = c1_buy and c2_buy and c3_buy and c4_buy and c5_buy and longBias and momentumFavorable and weeklyFilter and weeklyRSI > 50 and weeklyMF > 50
buySignal = buyCond and buyCond[1]
//// === Sell evaluation ===
// Similar logic as buy side but inverted.
c1_sell = rsi > 70 // RSI above overbought threshold
c2_sell = mfDown // Money Flow turning down
c3_sell = redDot // WaveTrend overbought reversal
c4_sell = ratingNeutralOrBuy // Analysts neutral or still buy
c5_sell = downsideCondition // Downside at least equal to upside
sellScore = (c1_sell?1:0) + (c2_sell?1:0) + (c3_sell?1:0) + (c4_sell?1:0) + (c5_sell?1:0)
// For exits require weekly filters to fail or long bias lost.
sellCond = c1_sell and c2_sell and c3_sell and c4_sell and c5_sell and (not longBias or not weeklyFilter or weeklyRSI < 50)
sellSignal = sellCond and sellCond[1]
// Plot composite scores for quick reference.
plot(buyScore, "Buy Score", color=color.green)
plot(sellScore, "Sell Score", color=color.red)
//// === Confidence table ===
// Shows which of the five buy/sell checks are currently met.
var table status = table.new(position.top_right, 5, 2, border_width=1)
if barstate.islast
table.cell(status, 0, 0, "RSI", bgcolor=c1_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 1, 0, "MF", bgcolor=c2_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 2, 0, "Dot", bgcolor=c3_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 3, 0, "Rating", bgcolor=c4_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 4, 0, "Target", bgcolor=c5_buy?color.new(color.green,0):color.new(color.red,0))
table.cell(status, 0, 1, "RSI>70", bgcolor=c1_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 1, 1, "MF down",bgcolor=c2_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 2, 1, "Red dot", bgcolor=c3_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 3, 1, "Rating", bgcolor=c4_sell?color.new(color.red,0):color.new(color.green,0))
table.cell(status, 4, 1, "Target", bgcolor=c5_sell?color.new(color.red,0):color.new(color.green,0))
//// === Alert text ===
// Include key metrics in alerts so the chart doesn't need to be opened.
buyMsg = "BUY: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
sellMsg = "SELL: RSI " + str.tostring(rsi, "#.##") +
", MF " + str.tostring(mf, "#.##") +
", Upside " + str.tostring(upsidePct, "#.##") + "%" +
", Downside " + str.tostring(downsidePct, "#.##") + "%" +
", Rating " + str.tostring(rating, "#.##")
// Alert conditions use static messages; dynamic data is sent via `alert()`
alertcondition(buySignal, title="Buy Signal", message="Buy conditions met")
alertcondition(sellSignal, title="Sell Signal", message="Sell conditions met")
if buySignal
alert(buyMsg, alert.freq_once_per_bar_close)
if sellSignal
alert(sellMsg, alert.freq_once_per_bar_close)
//// === Watch-out flags ===
// Gentle warnings when trends weaken but before full sell signals.
warnRSI = rsi > 65 and rsi[1] <= 65
warnAnalyst = upsidePct < 2 * downsidePct and upsidePct > downsidePct
alertcondition(warnRSI, title="RSI Watch", message="RSI creeping above 65")
alertcondition(warnAnalyst, title="Analyst Watch", message="Analyst upside shrinking")
if warnRSI
alert("RSI creeping above 65: " + str.tostring(rsi, "#.##"), alert.freq_once_per_bar_close)
if warnAnalyst
alert("Analyst upside shrinking: up " + str.tostring(upsidePct, "#.##") + "% vs down " + str.tostring(downsidePct, "#.##") + "%", alert.freq_once_per_bar_close)
//// === Plot bias moving averages ===
plot(ema50, color=color.orange, title="EMA50")
plot(ema200, color=color.blue, title="EMA200")
//// === Cross alerts for context ===
goldenCross = ta.crossover(ema50, ema200)
deathCross = ta.crossunder(ema50, ema200)
alertcondition(goldenCross, title="Golden Cross", message="50 EMA crossed above 200 EMA")
alertcondition(deathCross, title="Death Cross", message="50 EMA crossed below 200 EMA")
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.