OPEN-SOURCE SCRIPT
💼 Momentum SNR VIP

//version=5
indicator("Momentum", overlay=true)
// === SNR Detection ===
lookback = input.int(20, "Lookback for S/R", minval=5)
pivotHigh = ta.pivothigh(high, lookback, lookback)
pivotLow = ta.pivotlow(low, lookback, lookback)
// Plot SNR Zones
plotshape(pivotHigh, title="Resistance", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
plotshape(pivotLow, title="Support", location=location.belowbar, color=color.blue, style=shape.triangleup, size=size.small)
// === Price Action Detection ===
// Bullish Engulfing
bullishEngulfing = close[1] < open[1] and close > open and close > open[1] and open <= close[1]
// Bearish Engulfing
bearishEngulfing = close[1] > open[1] and close < open and close < open[1] and open >= close[1]
// Pin Bar Bullish
bullishPinBar = close > open and (low - math.min(open, close)) > 1.5 * (math.abs(close - open))
// Pin Bar Bearish
bearishPinBar = close < open and (math.max(open, close) - high) > 1.5 * (math.abs(close - open))
// === Combined Signal at SNR ===
supportZone = not na(pivotLow)
resistanceZone = not na(pivotHigh)
buySignal = (bullishEngulfing or bullishPinBar) and supportZone
sellSignal = (bearishEngulfing or bearishPinBar) and resistanceZone
// Plot Buy/Sell Arrows
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// === SL & TP Calculation ===
rr_ratio = input.float(2.0, "Risk Reward Ratio", minval=0.5, step=0.5)
buySL = low
buyTP = close + (close - low) * rr_ratio
sellSL = high
sellTP = close - (high - close) * rr_ratio
plot(buySignal ? buySL : na, title="Buy SL", color=color.red, style=plot.style_linebr, linewidth=1)
plot(buySignal ? buyTP : na, title="Buy TP", color=color.green, style=plot.style_linebr, linewidth=1)
plot(sellSignal ? sellSL : na, title="Sell SL", color=color.red, style=plot.style_linebr, linewidth=1)
plot(sellSignal ? sellTP : na, title="Sell TP", color=color.green, style=plot.style_linebr, linewidth=1)
// === Alerts ===
alertcondition(buySignal, title="Buy Alert", message="GOLD: Potential BUY @ SNR Zone + Price Action")
alertcondition(sellSignal, title="Sell Alert", message="GOLD: Potential SELL @ SNR Zone + Price Action")
indicator("Momentum", overlay=true)
// === SNR Detection ===
lookback = input.int(20, "Lookback for S/R", minval=5)
pivotHigh = ta.pivothigh(high, lookback, lookback)
pivotLow = ta.pivotlow(low, lookback, lookback)
// Plot SNR Zones
plotshape(pivotHigh, title="Resistance", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
plotshape(pivotLow, title="Support", location=location.belowbar, color=color.blue, style=shape.triangleup, size=size.small)
// === Price Action Detection ===
// Bullish Engulfing
bullishEngulfing = close[1] < open[1] and close > open and close > open[1] and open <= close[1]
// Bearish Engulfing
bearishEngulfing = close[1] > open[1] and close < open and close < open[1] and open >= close[1]
// Pin Bar Bullish
bullishPinBar = close > open and (low - math.min(open, close)) > 1.5 * (math.abs(close - open))
// Pin Bar Bearish
bearishPinBar = close < open and (math.max(open, close) - high) > 1.5 * (math.abs(close - open))
// === Combined Signal at SNR ===
supportZone = not na(pivotLow)
resistanceZone = not na(pivotHigh)
buySignal = (bullishEngulfing or bullishPinBar) and supportZone
sellSignal = (bearishEngulfing or bearishPinBar) and resistanceZone
// Plot Buy/Sell Arrows
plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// === SL & TP Calculation ===
rr_ratio = input.float(2.0, "Risk Reward Ratio", minval=0.5, step=0.5)
buySL = low
buyTP = close + (close - low) * rr_ratio
sellSL = high
sellTP = close - (high - close) * rr_ratio
plot(buySignal ? buySL : na, title="Buy SL", color=color.red, style=plot.style_linebr, linewidth=1)
plot(buySignal ? buyTP : na, title="Buy TP", color=color.green, style=plot.style_linebr, linewidth=1)
plot(sellSignal ? sellSL : na, title="Sell SL", color=color.red, style=plot.style_linebr, linewidth=1)
plot(sellSignal ? sellTP : na, title="Sell TP", color=color.green, style=plot.style_linebr, linewidth=1)
// === Alerts ===
alertcondition(buySignal, title="Buy Alert", message="GOLD: Potential BUY @ SNR Zone + Price Action")
alertcondition(sellSignal, title="Sell Alert", message="GOLD: Potential SELL @ SNR Zone + Price Action")
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。