OPEN-SOURCE SCRIPT

Oversold Screener · v4

43
# Step-2 Oversold Screener · v3.3

US equities · 15-minute event engine · AVWAP entries A–F · optional CVD/RSI/Z guards

## What this script does

Finds short, emotion-driven selloffs in large, healthy US stocks and turns them into actionable, right-side opportunities.
On a qualified 15-minute close it:

1. emits a minimal webhook so your backend/AI can vet the news and fundamentals, and
2. anchors an Event-AVWAP and plots ±1/±2/±3σ bands to guide entries A–F as price mean-reverts.

The logic runs in a fixed 15-minute space, independent of the chart timeframe you view.

## How an event is detected (Step-2 signal)

All conditions are evaluated on 15-minute data, including extended hours.

Depth, measured vs yesterday’s RTH reference

* Reference = min(yesterday’s RTH VWAP proxy, yesterday’s Close).
* 4h depth: current price vs reference across 16×15m bars ≤ threshold (default −4%).
* 8h depth: lowest close across the last 32×15m bars vs reference ≤ threshold (default −6%).

Relative underperformance

* Versus market ETF (SPY/QQQ) and sector ETF (XLK/XLF/XLY… or KWEB/CQQQ).
* Uses the same 16/32×15m windows; stock must be weaker by at least the set margins (default −3%).

Macro circuit breakers (any one trips = suppress signal)

* VIX level ≥ fuse (default 28).
* Market 4h/8h drawdown ≤ limits (default −2.0% / −3.5%).
* Sector 4h/8h drawdown ≤ limits (default −2.5% / −4.0%).

Momentum and distribution guards

* RSI(1h) < 30 by default (computed from 15m series).
* Optional Z-score filters: stock Z ≤ zTrig, and macro Z floors for market/sector.
* Cooldown per symbol so you don’t get spammed by repeated events.

When the event closes, the script posts a tiny JSON to your alert webhook and pins an on-chart “S2” marker at the event bar.

## Event-AVWAP and bands

From the event bar forward the script computes AVWAP natively in 15m space and draws bands at ±1σ/±2σ/±3σ.
σ is a rolling standard deviation of typical price with optional EMA smoothing and an optional cap.

Why this helps

* AVWAP from the shock timestamp approximates the crowd’s average position after the selloff.
* Reclaiming key bands often marks the start of orderly mean reversion rather than a dead-cat bounce.

## Entry proposals A–F (right-side confirmations)

Each entry requires first touching a lower band, then reclaiming a higher band.

A touch ≤ −2σ, then cross up through −1σ
B touch ≤ −1σ, then reclaim AVWAP
C break above −1σ, retest near −1σ within N bars, then bounce
D after compression (low ATR%), reclaim AVWAP
E touch ≤ −3σ, then cross up through −2σ
F touch ≤ −3σ, then cross up through −1σ (fast, aggressive)

Labeling hygiene

* Only the first three occurrences of each type A–F are shown within a one-week window after the event.
* A debounce interval avoids over-labeling across adjacent bars.

## Optional CVD gate (order-flow confirmation)

When enabled, entries must also pass a 15-minute CVD gate that looks for sell pressure exhaustion and a turn-up in cumulative delta.
Defaults are conservative; start with CVD off until you’re comfortable, then enable to filter chop after capitulations.

## Alert payload (minimal by design)

On the event bar close the script fires one alert with a tiny JSON that is easy to route and process in bulk:

```json
{
"event": "Crash_signal_15m",
"symbol": "NVDA",
"symbol_id": "NASDAQ:NVDA",
"ts_alert_15m_ms": 1730898900000,
"ts_alert_15m_local": "2025-11-06 10:45"
}
```

Notes

* ts_alert_15m_ms is the 15-minute close time in milliseconds since epoch (UTC reference).
* ts_alert_15m_local uses your chart’s timezone for readability.

Optional: a 24-hour streaming mode can resend this minimal payload on every 15-minute close during the day after the event (tiny patch available on request).

## Inputs you will actually touch

Bench/Sector symbols

* Bench: SPY or QQQ. Sector: XLK/XLF/XLY… or KWEB/CQQQ depending on the name.

Depth and relative thresholds

* 4h depth ≤ −4%, 8h depth ≤ −6%.
* Relative to market/sector ≤ −3% each.

Macro fuses

* VIX ≥ 28; market ≤ −2.0%/−3.5%; sector ≤ −2.5%/−4.0%.

Z/RSI guards

* Z window 80 bars (15m), stock zTrig ≤ −1.5, macro floors ≥ −1.0.
* RSI(1h) < 30.

AVWAP band engine

* σ EMA length 3; σ cap off by default.
* Retest window for entry C: 24 bars (≈6 hours).

Presentation and hygiene

* One-week entry window; per-type cap 3; debounce 8×15m bars.
* Signal table on/off, label pinning on/off.

## How to run it

1. Open a 15-minute chart (extended hours enabled recommended).
2. Add the indicator and choose Bench/Sector for the names you are reviewing.
3. Create a single alert per chart with Condition = Any alert() function call and Options = Once per bar close.
4. Point the alert to your webhook URL (or use app/email if you don’t have a URL).
5. Let your backend/AI receive the minimal JSON, do the news/fundamentals check, and decide Allow / Hold / Reject.
6. For Allowed names, use the on-chart A–F markers to stage in; manage risk against Event-AVWAP and upper HVNs/POC.

## Defaults that work well

* RSI(1h) < 30
* Depth 4h/8h ≤ −4%/−6% vs yesterday’s reference
* Relative to market/sector ≤ −3%
* Z: stock ≤ −1.5; macro floors ≥ −1.0
* Fuses: VIX ≥ 28; market ≤ −2.0%/−3.5%; sector ≤ −2.5%/−4.0%
* Bands: σ EMA = 3; no σ cap; one-week window; 3 labels per type

## Notes and limitations

* This is an indicator, not an auto-trader. Position sizing and exits are up to you.
* Designed for liquid US equities; thin ADRs and micro-caps are noisy.
* All event logic and entries are evaluated on bar close; AVWAP and bands do not repaint.
* If you need to monitor many symbols without a server, a Scanner variant can batch 10–17 tickers per script and alert without a webhook.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。