OPEN-SOURCE SCRIPT
My script

//version=5
indicator("LTF Multi-Condition BUY Signal (v5 clean)", overlay=true, max_labels_count=100, max_lines_count=100)
// ───────────────── INPUTS ─────────────────
pivot_len = input.int(4, "Pivot sensitivity (structure)", minval=2, maxval=12)
range_len = input.int(20, "Range lookback for breakout", minval=5)
htf_tf = input.timeframe("480", "HTF timeframe (8H+)")
reclaim_window = input.int(5, "Reclaim window (bars)", minval=1)
ema_fast_len = input.int(9, "EMA fast length")
ema_slow_len = input.int(21, "EMA slow length")
rsi_len = input.int(14, "RSI length")
rsi_pivot_len = input.int(4, "RSI pivot sensitivity")
rsi_div_lookback = input.int(30, "RSI divergence max lookback (bars)")
daily_vol_mult = input.float(1.0, "Daily volume vs SMA multiplier", step=0.1)
htf_vol_sma_len = input.int(20, "HTF volume SMA length")
require_reclaim = input.bool(true, "Require HTF reclaim")
use_aggressive_HL = input.bool(false, "Aggressive HL detection")
// ───────────────── BASE INDICATORS ─────────────────
emaFast = ta.ema(close, ema_fast_len)
emaSlow = ta.ema(close, ema_slow_len)
rsiVal = ta.rsi(close, rsi_len)
// ───────────────── DAILY CHECKS (VOLUME & OBV) ─────────────────
// Daily OBV and previous value
daily_obv = request.security(syminfo.tickerid, "D",
ta.cum(ta.change(close) > 0 ? volume : ta.change(close) < 0 ? -volume : 0))
daily_obv_prev = request.security(syminfo.tickerid, "D",
ta.cum(ta.change(close) > 0 ? volume : ta.change(close) < 0 ? -volume : 0)[1])
// Daily volume & SMA
daily_vol = request.security(syminfo.tickerid, "D", volume)
daily_vol_sma = request.security(syminfo.tickerid, "D", ta.sma(volume, 20))
daily_vol_ok = not na(daily_vol) and not na(daily_vol_sma) and daily_vol > daily_vol_sma * daily_vol_mult
daily_obv_ok = not na(daily_obv) and not na(daily_obv_prev) and daily_obv > daily_obv_prev
// ───────────────── HTF SUPPORT / RECLAIM ─────────────────
htf_high = request.security(syminfo.tickerid, htf_tf, high)
htf_low = request.security(syminfo.tickerid, htf_tf, low)
htf_close = request.security(syminfo.tickerid, htf_tf, close)
htf_volume = request.security(syminfo.tickerid, htf_tf, volume)
htf_vol_sma = request.security(syminfo.tickerid, htf_tf, ta.sma(volume, htf_vol_sma_len))
htf_bull_reject = not na(htf_high) and not na(htf_low) and not na(htf_close) and (htf_close - htf_low) > (htf_high - htf_close)
htf_vol_confirm = not na(htf_volume) and not na(htf_vol_sma) and htf_volume > htf_vol_sma
htf_support_level = (htf_bull_reject and htf_vol_confirm) ? htf_low : na
// Reclaim: LTF close back above HTF support within N bars
reclaimed_now = not na(htf_support_level) and close > htf_support_level and ta.barssince(close <= htf_support_level) <= reclaim_window
htf_reclaim_ok = require_reclaim ? reclaimed_now : true
// ───────────────── STRUCTURE: BOS & HL (CoC) ─────────────────
swingHighVal = ta.pivothigh(high, pivot_len, pivot_len)
swingLowVal = ta.pivotlow(low, pivot_len, pivot_len)
swingHighCond = not na(swingHighVal)
swingLowCond = not na(swingLowVal)
lastSwingHigh = ta.valuewhen(swingHighCond, swingHighVal, 0)
prevSwingHigh = ta.valuewhen(swingHighCond, swingHighVal, 1)
lastSwingLow = ta.valuewhen(swingLowCond, swingLowVal, 0)
prevSwingLow = ta.valuewhen(swingLowCond, swingLowVal, 1)
bos_bull = not na(prevSwingHigh) and close > prevSwingHigh
hl_confirm = not na(lastSwingLow) and not na(prevSwingLow) and lastSwingLow > prevSwingLow and ta.barssince(swingLowCond) <= 30
if use_aggressive_HL
hl_confirm := hl_confirm or (low > low[3] and ta.barssince(swingLowCond) <= 12)
// ───────────────── RSI BULLISH DIVERGENCE ─────────────────
rsiLowVal = ta.pivotlow(rsiVal, rsi_pivot_len, rsi_pivot_len)
rsiLowCond = not na(rsiLowVal)
priceAtRsiLowA = ta.valuewhen(rsiLowCond, low[rsi_pivot_len], 0)
priceAtRsiLowB = ta.valuewhen(rsiLowCond, low[rsi_pivot_len], 1)
rsiLowA = ta.valuewhen(rsiLowCond, rsiVal[rsi_pivot_len], 0)
rsiLowB = ta.valuewhen(rsiLowCond, rsiVal[rsi_pivot_len], 1)
rsi_div_ok = not na(priceAtRsiLowA) and not na(priceAtRsiLowB) and not na(rsiLowA) and not na(rsiLowB) and
(priceAtRsiLowA < priceAtRsiLowB) and (rsiLowA > rsiLowB) and ta.barssince(rsiLowCond) <= rsi_div_lookback
// ───────────────── RANGE BREAKOUT ─────────────────
range_high = ta.highest(high, range_len)
range_breakout = ta.crossover(close, range_high)
// ───────────────── EMA CROSS / TREND ─────────────────
ema_cross_happened = ta.crossover(emaFast, emaSlow)
ema_trend_ok = emaFast > emaSlow
// ───────────────── FINAL BUY CONDITION ─────────────────
all_price_checks = bos_bull and hl_confirm and rsi_div_ok and range_breakout
all_filter_checks = ema_trend_ok and ema_cross_happened and daily_vol_ok and daily_obv_ok and htf_reclaim_ok
buy_condition = all_price_checks and all_filter_checks
// ───────────────── PLOTS & ALERT ─────────────────
plotshape(
buy_condition,
title = "BUY Signal",
location = location.belowbar,
style = shape.labelup,
text = "BUY",
textcolor = color.white,
color = color.green,
size = size.small)
plot(htf_support_level, title="HTF Support", color=color.new(color.green, 0), linewidth=2, style=plot.style_linebr)
alertcondition(buy_condition, title="LTF BUY Signal", message="LTF BUY Signal on {{ticker}} ({{interval}}) — all conditions met")
indicator("LTF Multi-Condition BUY Signal (v5 clean)", overlay=true, max_labels_count=100, max_lines_count=100)
// ───────────────── INPUTS ─────────────────
pivot_len = input.int(4, "Pivot sensitivity (structure)", minval=2, maxval=12)
range_len = input.int(20, "Range lookback for breakout", minval=5)
htf_tf = input.timeframe("480", "HTF timeframe (8H+)")
reclaim_window = input.int(5, "Reclaim window (bars)", minval=1)
ema_fast_len = input.int(9, "EMA fast length")
ema_slow_len = input.int(21, "EMA slow length")
rsi_len = input.int(14, "RSI length")
rsi_pivot_len = input.int(4, "RSI pivot sensitivity")
rsi_div_lookback = input.int(30, "RSI divergence max lookback (bars)")
daily_vol_mult = input.float(1.0, "Daily volume vs SMA multiplier", step=0.1)
htf_vol_sma_len = input.int(20, "HTF volume SMA length")
require_reclaim = input.bool(true, "Require HTF reclaim")
use_aggressive_HL = input.bool(false, "Aggressive HL detection")
// ───────────────── BASE INDICATORS ─────────────────
emaFast = ta.ema(close, ema_fast_len)
emaSlow = ta.ema(close, ema_slow_len)
rsiVal = ta.rsi(close, rsi_len)
// ───────────────── DAILY CHECKS (VOLUME & OBV) ─────────────────
// Daily OBV and previous value
daily_obv = request.security(syminfo.tickerid, "D",
ta.cum(ta.change(close) > 0 ? volume : ta.change(close) < 0 ? -volume : 0))
daily_obv_prev = request.security(syminfo.tickerid, "D",
ta.cum(ta.change(close) > 0 ? volume : ta.change(close) < 0 ? -volume : 0)[1])
// Daily volume & SMA
daily_vol = request.security(syminfo.tickerid, "D", volume)
daily_vol_sma = request.security(syminfo.tickerid, "D", ta.sma(volume, 20))
daily_vol_ok = not na(daily_vol) and not na(daily_vol_sma) and daily_vol > daily_vol_sma * daily_vol_mult
daily_obv_ok = not na(daily_obv) and not na(daily_obv_prev) and daily_obv > daily_obv_prev
// ───────────────── HTF SUPPORT / RECLAIM ─────────────────
htf_high = request.security(syminfo.tickerid, htf_tf, high)
htf_low = request.security(syminfo.tickerid, htf_tf, low)
htf_close = request.security(syminfo.tickerid, htf_tf, close)
htf_volume = request.security(syminfo.tickerid, htf_tf, volume)
htf_vol_sma = request.security(syminfo.tickerid, htf_tf, ta.sma(volume, htf_vol_sma_len))
htf_bull_reject = not na(htf_high) and not na(htf_low) and not na(htf_close) and (htf_close - htf_low) > (htf_high - htf_close)
htf_vol_confirm = not na(htf_volume) and not na(htf_vol_sma) and htf_volume > htf_vol_sma
htf_support_level = (htf_bull_reject and htf_vol_confirm) ? htf_low : na
// Reclaim: LTF close back above HTF support within N bars
reclaimed_now = not na(htf_support_level) and close > htf_support_level and ta.barssince(close <= htf_support_level) <= reclaim_window
htf_reclaim_ok = require_reclaim ? reclaimed_now : true
// ───────────────── STRUCTURE: BOS & HL (CoC) ─────────────────
swingHighVal = ta.pivothigh(high, pivot_len, pivot_len)
swingLowVal = ta.pivotlow(low, pivot_len, pivot_len)
swingHighCond = not na(swingHighVal)
swingLowCond = not na(swingLowVal)
lastSwingHigh = ta.valuewhen(swingHighCond, swingHighVal, 0)
prevSwingHigh = ta.valuewhen(swingHighCond, swingHighVal, 1)
lastSwingLow = ta.valuewhen(swingLowCond, swingLowVal, 0)
prevSwingLow = ta.valuewhen(swingLowCond, swingLowVal, 1)
bos_bull = not na(prevSwingHigh) and close > prevSwingHigh
hl_confirm = not na(lastSwingLow) and not na(prevSwingLow) and lastSwingLow > prevSwingLow and ta.barssince(swingLowCond) <= 30
if use_aggressive_HL
hl_confirm := hl_confirm or (low > low[3] and ta.barssince(swingLowCond) <= 12)
// ───────────────── RSI BULLISH DIVERGENCE ─────────────────
rsiLowVal = ta.pivotlow(rsiVal, rsi_pivot_len, rsi_pivot_len)
rsiLowCond = not na(rsiLowVal)
priceAtRsiLowA = ta.valuewhen(rsiLowCond, low[rsi_pivot_len], 0)
priceAtRsiLowB = ta.valuewhen(rsiLowCond, low[rsi_pivot_len], 1)
rsiLowA = ta.valuewhen(rsiLowCond, rsiVal[rsi_pivot_len], 0)
rsiLowB = ta.valuewhen(rsiLowCond, rsiVal[rsi_pivot_len], 1)
rsi_div_ok = not na(priceAtRsiLowA) and not na(priceAtRsiLowB) and not na(rsiLowA) and not na(rsiLowB) and
(priceAtRsiLowA < priceAtRsiLowB) and (rsiLowA > rsiLowB) and ta.barssince(rsiLowCond) <= rsi_div_lookback
// ───────────────── RANGE BREAKOUT ─────────────────
range_high = ta.highest(high, range_len)
range_breakout = ta.crossover(close, range_high)
// ───────────────── EMA CROSS / TREND ─────────────────
ema_cross_happened = ta.crossover(emaFast, emaSlow)
ema_trend_ok = emaFast > emaSlow
// ───────────────── FINAL BUY CONDITION ─────────────────
all_price_checks = bos_bull and hl_confirm and rsi_div_ok and range_breakout
all_filter_checks = ema_trend_ok and ema_cross_happened and daily_vol_ok and daily_obv_ok and htf_reclaim_ok
buy_condition = all_price_checks and all_filter_checks
// ───────────────── PLOTS & ALERT ─────────────────
plotshape(
buy_condition,
title = "BUY Signal",
location = location.belowbar,
style = shape.labelup,
text = "BUY",
textcolor = color.white,
color = color.green,
size = size.small)
plot(htf_support_level, title="HTF Support", color=color.new(color.green, 0), linewidth=2, style=plot.style_linebr)
alertcondition(buy_condition, title="LTF BUY Signal", message="LTF BUY Signal on {{ticker}} ({{interval}}) — all conditions met")
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının yaratıcısı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının yaratıcısı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.