OPEN-SOURCE SCRIPT
A+ Confluence Alert (BTC filter) — Kailash

//version=5
indicator("A+ Confluence Alert (BTC filter) — Kailash", overlay=true)
// === USER INPUTS ===
btcTicker = input.symbol("BINANCE:BTCUSDT", "BTC symbol (for bias filter)")
btcHTF = input.timeframe("60", "BTC Higher TF (for bias)") // 1H
localHTF = input.timeframe("15", "Local bias TF") // 15m
ema_fast_len = input.int(20, "EMA fast length")
ema_slow_len = input.int(50, "EMA slow length")
vol_sma_len = input.int(20, "Volume SMA length")
vol_mult = input.float(1.5, "Volume spike multiplier", step=0.1)
liquidity_look = input.int(12, "Liquidity sweep lookback (bars)")
session_filter = input.bool(true, "Use session filter (NY window)")
ny_start = input.session("1300-2000", "NY session (UTC)")
// === FETCH BTC HIGHER-TF BIAS ===
btc_close_htf = request.security(btcTicker, btcHTF, close, lookahead=barmerge.lookahead_off)
btc_ema_fast = request.security(btcTicker, btcHTF, ta.ema(close, ema_fast_len), lookahead=barmerge.lookahead_off)
btc_ema_slow = request.security(btcTicker, btcHTF, ta.ema(close, ema_slow_len), lookahead=barmerge.lookahead_off)
btc_bias_long = btc_ema_fast > btc_ema_slow
btc_bias_short= btc_ema_fast < btc_ema_slow
// === LOCAL BIAS (on localHTF) for current chart symbol ===
local_close = request.security(syminfo.tickerid, localHTF, close, lookahead=barmerge.lookahead_off)
local_ema_f = request.security(syminfo.tickerid, localHTF, ta.ema(close, ema_fast_len), lookahead=barmerge.lookahead_off)
local_ema_s = request.security(syminfo.tickerid, localHTF, ta.ema(close, ema_slow_len), lookahead=barmerge.lookahead_off)
local_long = local_ema_f > local_ema_s
local_short = local_ema_f < local_ema_s
// === VOLUME SPIKE ===
vol_sma = ta.sma(volume, vol_sma_len)
vol_spike = volume > vol_sma * vol_mult
// === SIMPLE LIQUIDITY SWEEP DETECTION (proxy) ===
// Long-sweep: price made new local low (below recent lowest) and then reclaimed above that prior low.
// Short-sweep: symmetrical for highs.
recent_low = ta.lowest(low, liquidity_look)
recent_high = ta.highest(high, liquidity_look)
sweep_long = (low < recent_low[1]) and (close > recent_low[1]) // low punched lower, then close reclaimed
sweep_short= (high > recent_high[1]) and (close < recent_high[1]) // high pumped, then reclaimed down
// === ORDER-BLOCK RECLAIM PROXY ===
// Define last opposite directional candle high/low as "OB"
var float ob_high = na
var float ob_low = na
// Update order blocks when opposite direction candles form
if close[1] < open[1] // bearish candle
ob_high := high[1]
if close[1] > open[1] // bullish candle
ob_low := low[1]
// Reclaim conditions: price closes above recent bearish-high (for long), or below recent bullish-low (for short)
reclaim_long = not na(ob_high) and close > ob_high
reclaim_short = not na(ob_low) and close < ob_low
// === SESSION FILTER ===
in_session = true
if session_filter
in_session := not na(time(timeframe.period, ny_start))
// === FULL CONFLUENCE LOGIC ===
// Long confluence: BTC bias long, local bias long, sweep_long or reclaim_long, volume spike, in session
long_confluence = btc_bias_long and local_long and (sweep_long or reclaim_long) and vol_spike and in_session
// Short confluence: BTC bias short, local bias short, sweep_short or reclaim_short, volume spike, in session
short_confluence = btc_bias_short and local_short and (sweep_short or reclaim_short) and vol_spike and in_session
// === PLOTTING SIGNALS ON CHART ===
plotshape(long_confluence, title="A+ Long", style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, text="A+ Long")
plotshape(short_confluence, title="A+ Short", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, text="A+ Short")
// === ALERTS ===
alertcondition(long_confluence, title="A+ Confluence Long", message="A+ LONG: BTC bias long, local bias long, sweep/OB reclaim + volume spike. Symbol: {{ticker}}. Time: {{time}}")
alertcondition(short_confluence, title="A+ Confluence Short", message="A+ SHORT: BTC bias short, local bias short, sweep/OB reclaim + volume spike. Symbol: {{ticker}}. Time: {{time}}")
// === INFO BOX ===
var label info = na
if barstate.islast
label.delete(info)
info := label.new(x=bar_index, y=high, yloc=yloc.abovebar, style=label.style_label_left, text=
"A+ Long: " + (long_confluence ? "YES" : "NO") + "\n" +
"A+ Short: " + (short_confluence ? "YES" : "NO") + "\n" +
"BTC HTF Bias: " + (btc_bias_long ? "LONG" : btc_bias_short ? "SHORT" : "NEUTRAL") + "\n" +
"Local Bias: " + (local_long ? "LONG" : local_short ? "SHORT" : "NEUTRAL") + "\n" +
"VolSpike: " + (vol_spike ? "YES" : "NO"),
color=color.new(color.blue, 80), textcolor=color.white)
indicator("A+ Confluence Alert (BTC filter) — Kailash", overlay=true)
// === USER INPUTS ===
btcTicker = input.symbol("BINANCE:BTCUSDT", "BTC symbol (for bias filter)")
btcHTF = input.timeframe("60", "BTC Higher TF (for bias)") // 1H
localHTF = input.timeframe("15", "Local bias TF") // 15m
ema_fast_len = input.int(20, "EMA fast length")
ema_slow_len = input.int(50, "EMA slow length")
vol_sma_len = input.int(20, "Volume SMA length")
vol_mult = input.float(1.5, "Volume spike multiplier", step=0.1)
liquidity_look = input.int(12, "Liquidity sweep lookback (bars)")
session_filter = input.bool(true, "Use session filter (NY window)")
ny_start = input.session("1300-2000", "NY session (UTC)")
// === FETCH BTC HIGHER-TF BIAS ===
btc_close_htf = request.security(btcTicker, btcHTF, close, lookahead=barmerge.lookahead_off)
btc_ema_fast = request.security(btcTicker, btcHTF, ta.ema(close, ema_fast_len), lookahead=barmerge.lookahead_off)
btc_ema_slow = request.security(btcTicker, btcHTF, ta.ema(close, ema_slow_len), lookahead=barmerge.lookahead_off)
btc_bias_long = btc_ema_fast > btc_ema_slow
btc_bias_short= btc_ema_fast < btc_ema_slow
// === LOCAL BIAS (on localHTF) for current chart symbol ===
local_close = request.security(syminfo.tickerid, localHTF, close, lookahead=barmerge.lookahead_off)
local_ema_f = request.security(syminfo.tickerid, localHTF, ta.ema(close, ema_fast_len), lookahead=barmerge.lookahead_off)
local_ema_s = request.security(syminfo.tickerid, localHTF, ta.ema(close, ema_slow_len), lookahead=barmerge.lookahead_off)
local_long = local_ema_f > local_ema_s
local_short = local_ema_f < local_ema_s
// === VOLUME SPIKE ===
vol_sma = ta.sma(volume, vol_sma_len)
vol_spike = volume > vol_sma * vol_mult
// === SIMPLE LIQUIDITY SWEEP DETECTION (proxy) ===
// Long-sweep: price made new local low (below recent lowest) and then reclaimed above that prior low.
// Short-sweep: symmetrical for highs.
recent_low = ta.lowest(low, liquidity_look)
recent_high = ta.highest(high, liquidity_look)
sweep_long = (low < recent_low[1]) and (close > recent_low[1]) // low punched lower, then close reclaimed
sweep_short= (high > recent_high[1]) and (close < recent_high[1]) // high pumped, then reclaimed down
// === ORDER-BLOCK RECLAIM PROXY ===
// Define last opposite directional candle high/low as "OB"
var float ob_high = na
var float ob_low = na
// Update order blocks when opposite direction candles form
if close[1] < open[1] // bearish candle
ob_high := high[1]
if close[1] > open[1] // bullish candle
ob_low := low[1]
// Reclaim conditions: price closes above recent bearish-high (for long), or below recent bullish-low (for short)
reclaim_long = not na(ob_high) and close > ob_high
reclaim_short = not na(ob_low) and close < ob_low
// === SESSION FILTER ===
in_session = true
if session_filter
in_session := not na(time(timeframe.period, ny_start))
// === FULL CONFLUENCE LOGIC ===
// Long confluence: BTC bias long, local bias long, sweep_long or reclaim_long, volume spike, in session
long_confluence = btc_bias_long and local_long and (sweep_long or reclaim_long) and vol_spike and in_session
// Short confluence: BTC bias short, local bias short, sweep_short or reclaim_short, volume spike, in session
short_confluence = btc_bias_short and local_short and (sweep_short or reclaim_short) and vol_spike and in_session
// === PLOTTING SIGNALS ON CHART ===
plotshape(long_confluence, title="A+ Long", style=shape.labelup, location=location.belowbar, color=color.green, size=size.small, text="A+ Long")
plotshape(short_confluence, title="A+ Short", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.small, text="A+ Short")
// === ALERTS ===
alertcondition(long_confluence, title="A+ Confluence Long", message="A+ LONG: BTC bias long, local bias long, sweep/OB reclaim + volume spike. Symbol: {{ticker}}. Time: {{time}}")
alertcondition(short_confluence, title="A+ Confluence Short", message="A+ SHORT: BTC bias short, local bias short, sweep/OB reclaim + volume spike. Symbol: {{ticker}}. Time: {{time}}")
// === INFO BOX ===
var label info = na
if barstate.islast
label.delete(info)
info := label.new(x=bar_index, y=high, yloc=yloc.abovebar, style=label.style_label_left, text=
"A+ Long: " + (long_confluence ? "YES" : "NO") + "\n" +
"A+ Short: " + (short_confluence ? "YES" : "NO") + "\n" +
"BTC HTF Bias: " + (btc_bias_long ? "LONG" : btc_bias_short ? "SHORT" : "NEUTRAL") + "\n" +
"Local Bias: " + (local_long ? "LONG" : local_short ? "SHORT" : "NEUTRAL") + "\n" +
"VolSpike: " + (vol_spike ? "YES" : "NO"),
color=color.new(color.blue, 80), textcolor=color.white)
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.