OPEN-SOURCE SCRIPT

AI Oversold Swing - Screener

899
//version=5
indicator("AI Oversold Swing - Screener", overlay=false)

// ─────────────────────────
// USER INPUTS
// ─────────────────────────
maxPrice = input.float(75.0, "Max Price ($)")
rsiLen = input.int(14, "RSI Length")
rsiOversold = input.float(35.0, "RSI Oversold Level")

bbLen = input.int(20, "BB Length")
bbMult = input.float(2.0, "BB StdDev")

supportLen = input.int(20, "Support Lookback (days)")
nearSupportPct = input.float(1.5, "Near Support %")
undercutPct = input.float(0.5, "Allowed Undercut %")

atrLen = input.int(14, "ATR Length")
maxATRfromSup = input.float(1.0, "Max ATR From Support")

minDollarVol = input.float(75000000.0, "Min Dollar Volume", step=1000000)

requireTrigger = input.bool(false, "Require Reversal Trigger")

// ─────────────────────────
// DAILY DATA (screener uses indicator outputs)
// ─────────────────────────
dClose = request.security(syminfo.tickerid, "D", close)
dLow = request.security(syminfo.tickerid, "D", low)
dVol = request.security(syminfo.tickerid, "D", volume)
dPrevC = request.security(syminfo.tickerid, "D", close[1])

// ─────────────────────────
// INDICATORS
// ─────────────────────────
rsi = ta.rsi(dClose, rsiLen)

basis = ta.sma(dClose, bbLen)
dev = bbMult * ta.stdev(dClose, bbLen)
bbLow = basis - dev

atr = request.security(syminfo.tickerid, "D", ta.atr(atrLen))

support = ta.lowest(dLow, supportLen)

distPct = support > 0 ? (dClose - support) / support * 100.0 : na
distATR = atr > 0 ? (dClose - support) / atr : na

dollarVol = dClose * dVol

// ─────────────────────────
// CONDITIONS
// ─────────────────────────
priceOK = dClose > 0 and dClose <= maxPrice
liqOK = dollarVol >= minDollarVol

oversold = (rsi <= rsiOversold) and (dClose <= bbLow)

nearSup =
support > 0 and
dClose <= support * (1 + nearSupportPct / 100.0) and
dClose >= support * (1 - undercutPct / 100.0) and
distATR <= maxATRfromSup

setup = priceOK and liqOK and oversold and nearSup

// Optional reversal confirmation
rsiReversal = ta.crossover(rsi, rsiOversold)
greenCandle = dClose > dPrevC
trigger = rsiReversal or greenCandle

signal = requireTrigger ? (setup and trigger) : setup

// ─────────────────────────
// SCREENER OUTPUTS
// ─────────────────────────
plot(signal ? 1 : 0, title="Signal (1 = YES)")
plot(rsi, title="RSI (Daily)")
plot(distPct, title="Dist to Support % (Daily)")
plot(distATR, title="Dist to Support ATR (Daily)")
plot(dollarVol, title="Dollar Volume (Daily)")

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.