OPEN-SOURCE SCRIPT
XAUUSD Sniper Setup (Pre-Arrows + SL/TP)

//version=5
indicator("XAUUSD Sniper Setup (Pre-Arrows + SL/TP)", overlay=true)
// === Inputs ===
rangePeriod = input.int(20, "Lookback Bars for Zone", minval=5)
maxRangePercent = input.float(0.08, "Max Range % for Consolidation", step=0.01)
tpMultiplier = input.float(1.5, "TP Multiplier")
slMultiplier = input.float(1.0, "SL Multiplier")
// === Consolidation Detection ===
highestPrice = ta.highest(high, rangePeriod)
lowestPrice = ta.lowest(low, rangePeriod)
priceRange = highestPrice - lowestPrice
percentRange = (priceRange / close) * 100
isConsolidation = percentRange < maxRangePercent
// === Zones ===
demandZone = lowestPrice
supplyZone = highestPrice
// === Plot Consolidation Zone Background ===
bgcolor(isConsolidation ? color.new(color.gray, 85) : na)
// === Plot Potential Buy/Sell Levels ===
plot(isConsolidation ? demandZone : na, color=color.green, title="Potential Buy Level", linewidth=2)
plot(isConsolidation ? supplyZone : na, color=color.red, title="Potential Sell Level", linewidth=2)
// === Liquidity Sweep ===
liquidityTakenBelow = low < demandZone
liquidityTakenAbove = high > supplyZone
// === Engulfing Candles ===
bullishEngulfing = close > open and close[1] < open[1] and close > open[1]
bearishEngulfing = close < open and close[1] > open[1] and close < open[1]
// === Break of Structure ===
bosUp = high > ta.highest(high[1], 5)
bosDown = low < ta.lowest(low[1], 5)
// === Sniper Entry Conditions ===
buySignal = isConsolidation and liquidityTakenBelow and bullishEngulfing and bosUp
sellSignal = isConsolidation and liquidityTakenAbove and bearishEngulfing and bosDown
// === SL & TP Levels ===
slBuy = demandZone - (priceRange * slMultiplier)
tpBuy = close + (priceRange * tpMultiplier)
slSell = supplyZone + (priceRange * slMultiplier)
tpSell = close - (priceRange * tpMultiplier)
// === PRE-ARROWS (Show Before Breakout) ===
preBuyArrow = isConsolidation ? 1 : na
preSellArrow = isConsolidation ? -1 : na
plotarrow(preBuyArrow, colorup=color.new(color.green, 50), maxheight=20, minheight=20, title="Pre-Buy Arrow")
plotarrow(preSellArrow, colordown=color.new(color.red, 50), maxheight=20, minheight=20, title="Pre-Sell Arrow")
// === SNIPER CONFIRMATION ARROWS ===
buyArrow = buySignal ? 1 : na
sellArrow = sellSignal ? -1 : na
plotarrow(buyArrow, colorup=color.green, maxheight=60, minheight=60, title="Sniper BUY Arrow")
plotarrow(sellArrow, colordown=color.red, maxheight=60, minheight=60, title="Sniper SELL Arrow")
// === BUY SIGNAL ===
if buySignal
label.new(bar_index, low, "BUY\nSL/TP Added", style=label.style_label_up, color=color.green, textcolor=color.white)
line.new(bar_index, slBuy, bar_index + 5, slBuy, color=color.red, style=line.style_dotted)
line.new(bar_index, tpBuy, bar_index + 5, tpBuy, color=color.green, style=line.style_dotted)
label.new(bar_index, slBuy, "SL", color=color.red, style=label.style_label_down)
label.new(bar_index, tpBuy, "TP", color=color.green, style=label.style_label_up)
// === SELL SIGNAL ===
if sellSignal
label.new(bar_index, high, "SELL\nSL/TP Added", style=label.style_label_down, color=color.red, textcolor=color.white)
line.new(bar_index, slSell, bar_index + 5, slSell, color=color.red, style=line.style_dotted)
line.new(bar_index, tpSell, bar_index + 5, tpSell, color=color.green, style=line.style_dotted)
label.new(bar_index, slSell, "SL", color=color.red, style=label.style_label_up)
label.new(bar_index, tpSell, "TP", color=color.green, style=label.style_label_down)
// === Alerts ===
alertcondition(buySignal, title="Sniper BUY", message="Sniper BUY setup on XAUUSD")
alertcondition(sellSignal, title="Sniper SELL", message="Sniper SELL setup on XAUUSD")
XAUUSD
indicator("XAUUSD Sniper Setup (Pre-Arrows + SL/TP)", overlay=true)
// === Inputs ===
rangePeriod = input.int(20, "Lookback Bars for Zone", minval=5)
maxRangePercent = input.float(0.08, "Max Range % for Consolidation", step=0.01)
tpMultiplier = input.float(1.5, "TP Multiplier")
slMultiplier = input.float(1.0, "SL Multiplier")
// === Consolidation Detection ===
highestPrice = ta.highest(high, rangePeriod)
lowestPrice = ta.lowest(low, rangePeriod)
priceRange = highestPrice - lowestPrice
percentRange = (priceRange / close) * 100
isConsolidation = percentRange < maxRangePercent
// === Zones ===
demandZone = lowestPrice
supplyZone = highestPrice
// === Plot Consolidation Zone Background ===
bgcolor(isConsolidation ? color.new(color.gray, 85) : na)
// === Plot Potential Buy/Sell Levels ===
plot(isConsolidation ? demandZone : na, color=color.green, title="Potential Buy Level", linewidth=2)
plot(isConsolidation ? supplyZone : na, color=color.red, title="Potential Sell Level", linewidth=2)
// === Liquidity Sweep ===
liquidityTakenBelow = low < demandZone
liquidityTakenAbove = high > supplyZone
// === Engulfing Candles ===
bullishEngulfing = close > open and close[1] < open[1] and close > open[1]
bearishEngulfing = close < open and close[1] > open[1] and close < open[1]
// === Break of Structure ===
bosUp = high > ta.highest(high[1], 5)
bosDown = low < ta.lowest(low[1], 5)
// === Sniper Entry Conditions ===
buySignal = isConsolidation and liquidityTakenBelow and bullishEngulfing and bosUp
sellSignal = isConsolidation and liquidityTakenAbove and bearishEngulfing and bosDown
// === SL & TP Levels ===
slBuy = demandZone - (priceRange * slMultiplier)
tpBuy = close + (priceRange * tpMultiplier)
slSell = supplyZone + (priceRange * slMultiplier)
tpSell = close - (priceRange * tpMultiplier)
// === PRE-ARROWS (Show Before Breakout) ===
preBuyArrow = isConsolidation ? 1 : na
preSellArrow = isConsolidation ? -1 : na
plotarrow(preBuyArrow, colorup=color.new(color.green, 50), maxheight=20, minheight=20, title="Pre-Buy Arrow")
plotarrow(preSellArrow, colordown=color.new(color.red, 50), maxheight=20, minheight=20, title="Pre-Sell Arrow")
// === SNIPER CONFIRMATION ARROWS ===
buyArrow = buySignal ? 1 : na
sellArrow = sellSignal ? -1 : na
plotarrow(buyArrow, colorup=color.green, maxheight=60, minheight=60, title="Sniper BUY Arrow")
plotarrow(sellArrow, colordown=color.red, maxheight=60, minheight=60, title="Sniper SELL Arrow")
// === BUY SIGNAL ===
if buySignal
label.new(bar_index, low, "BUY\nSL/TP Added", style=label.style_label_up, color=color.green, textcolor=color.white)
line.new(bar_index, slBuy, bar_index + 5, slBuy, color=color.red, style=line.style_dotted)
line.new(bar_index, tpBuy, bar_index + 5, tpBuy, color=color.green, style=line.style_dotted)
label.new(bar_index, slBuy, "SL", color=color.red, style=label.style_label_down)
label.new(bar_index, tpBuy, "TP", color=color.green, style=label.style_label_up)
// === SELL SIGNAL ===
if sellSignal
label.new(bar_index, high, "SELL\nSL/TP Added", style=label.style_label_down, color=color.red, textcolor=color.white)
line.new(bar_index, slSell, bar_index + 5, slSell, color=color.red, style=line.style_dotted)
line.new(bar_index, tpSell, bar_index + 5, tpSell, color=color.green, style=line.style_dotted)
label.new(bar_index, slSell, "SL", color=color.red, style=label.style_label_up)
label.new(bar_index, tpSell, "TP", color=color.green, style=label.style_label_down)
// === Alerts ===
alertcondition(buySignal, title="Sniper BUY", message="Sniper BUY setup on XAUUSD")
alertcondition(sellSignal, title="Sniper SELL", message="Sniper SELL setup on XAUUSD")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.