OPEN-SOURCE SCRIPT
업데이트됨

4h 相对超跌筛选器 · Webhook v2.0

289
## 指标用途

用于你的「框架第2步」:在**美股 RTH**里,按**4h 收盘**(06:30–10:30 PT 为首根)筛出相对大盘/行业**显著超跌**且结构健康的候选标的,并可**通过 Webhook 自动推送**`symbol + ts`给下游 AI 执行新闻甄别(第3步)与进出场评估(第4步)。

## 工作原理(核心逻辑)

* **结构健康**:最近 80 根 4h 中,收盘 > 4h_SMA50 的占比 ≥ 阈值(默认 55%)。
* **跌深条件**:4h 跌幅 ≤ −4%,且近两根累计(≈8h)≤ −6%。
* **相对劣化**:相对大盘(SPY/QQQ)与相对行业(XLK/XLF/… 或 KWEB/CQQQ)各 ≤ −3%。
* **流动性与价格**:ADV20_USD ≥ 2000 万;价格 ≥ 3 美元。
* **只在 4h 收盘刻评估与触发**,历史点位全部保留,便于回放核验。
* **冷却**:同一标的信号间隔 ≥ N 天(默认 10)。

## 主要输入参数

* **bench / sector**:大盘与行业基准(例:SPY/QQQ,XLK/XLF/XLY;中概用 KWEB/CQQQ)。
* **advMinUSD / priceMin**:20 日美元成交额下限、最小价格。
* **pctAboveTh**:结构健康阈值(%)。
* **drop4hTh / drop8hTh**:4h/8h 跌幅阈值(%)。
* **relMktTh / relSecTh**:相对大盘/行业阈值(%)。
* **coolDays**:冷却天数。
* **fromDate**:仅显示此日期后的历史信号(图表拥挤时可用)。
* **showTable / tableRows**:是否显示右上角“最近信号表”及行数。

## 图表信号

* **S2 绿点**:当根 4h 收盘满足全部筛选条件。
* **右上角表格**:滚动列出最近 N 条命中(`SYMBOL @ yyyy-MM-dd HH:mm`,按图表本地时区)。

## Webhook 联动(生产用)

1. 添加指标 → 🔔 新建警报(Alert):

* **Condition**:`Any alert() function call`
* **Options**:`Once per bar close`
* **Webhook URL**:填你的接收地址(可带 `?token=...`)
* **Message**:留空(脚本内部 `alert(payload)` 会发送 JSON)。
2. 典型 JSON 载荷(举例):

```json
{
"event": "step2_signal",
"symbol": "LULU",
"symbol_id": "NASDAQ:LULU",
"venue": "NASDAQ",
"bench": "SPY",
"sector": "XLY",
"ts_bar_close_ms": 1754524200000,
"ts_bar_close_local": "2025-06-06 10:30",
"price_close": 318.42,
"ret_4h_pct": -5.30,
"ret_8h_pct": -7.45,
"rel_mkt_pct": -4.90,
"rel_sec_pct": -3.80
}
```

> 建议以 `symbol + ts_bar_close_ms` 做去重键;接收端先快速 `200 OK`,后续异步处理并交给第3步 AI。

## 使用建议

* **时间框架**:任意周期可用,指标内部统一拉取 240 分钟数据并仅在 4h 收盘刻触发。
* **行业映射**:尽量选与个股业务最贴近的 ETF;中国 ADR 可用 `PGJ/KWEB/CQQQ` 叠加细分行业对照。
* **回放验证**:Bar Replay **不发送真实 Webhook**;仅用于查看历史命中与表格。测试接收端请用 Alert 面板的 **Test**。

## 适配说明

* Pine Script **v5**。
* 不含成分筛查逻辑(请在你的 500–600 只候选池内使用)。
* 数字常量不使用下划线分隔;如需大数可用 `20000000` 或 `2e7`。

## 常见问题

* ⛔️ 报错 `tostring(...)`:Pine 无时间格式化重载,脚本已内置 `timeToStr()`。
* ⛔️ `syminfo.exchange` 不存在:已改用 `syminfo.prefix`(交易所前缀)。
* ⛔️ 多行字符串拼接报 `line continuation`:本脚本已用括号包裹或 `str.format` 规避。

## 免责声明

该指标仅供筛选与研究使用,不构成投资建议。请结合你的第3步新闻/基本面甄别与第4步执行规则共同决策。
릴리즈 노트
4h 相对超跌筛选器 · Webhook v2.0

## 作用

在**美股 RTH**以**4h收盘**为准筛出:结构健康、当根跌幅大且**相对大盘/行业显著更弱**的标的;并在触发时通过 **Webhook** 把 `symbol + ts` 等关键字段 POST 给你的后续 AI(“第3步新闻甄别 / 第4步执行”)。

## 触发机制(严格在已收盘的4h上)

* 只在**新一根 4h 开始的那一刻**评估上一根 4h 的数据;
* 告警与显示使用**上一根 4h 的收盘时间**(例:06:30–10:30 这根 → 时间写 10:30);
* 图上标记 `offset = -1`,绿点画在**刚收完的那根 4h**上;
* 可选“**仅监测每日首根 4h**(06:30–10:30)”。

## 核心判定(上一根 4h 数据)

1. **结构健康**:近 80 根 4h 中,`收盘 > 4h_SMA50` 的**占比 ≥ 阈值**(默认 55%)。

* 注意:占比在 **4h 周期内一次性计算**,与图表分辨率无关。
2. **跌深**:上一根 `4h_ret ≤ −4%` 且 `8h_ret ≤ −6%`。
3. **相对劣化**:

* 对**大盘**(SPY/QQQ 二选一)`ret_4h − ret_4h_bench ≤ −3%`;
* 对**行业ETF**(如 XLK/XLF/XLY,或 KWEB/CQQQ)`ret_4h − ret_4h_sector ≤ −3%`。
4. **流动性/价格**:`ADV20_USD ≥ 2000万`、`收盘价 ≥ 3`。
5. **冷却**:同一标的信号间隔 ≥ N 天(默认 10)。

## 主要参数

* **bench / sector**:大盘与行业基准。
* **advMinUSD / priceMin**:流动性与最低价过滤。
* **pctAboveTh / drop4hTh / drop8hTh / relMktTh / relSecTh**:阈值组。
* **coolDays**:冷却天数。
* **onlyFirst**:仅每日首根 4h。
* **fromDate**:仅显示该日期之后的历史信号(图表本地时区)。
* **showTable / tableRows**:右上角“最近信号表”。

## 图表元素

* **S2 绿点**:上一根 4h 满足全部条件。
* **最近信号表**:滚动展示 `SYMBOL @ yyyy-MM-dd HH:mm`(本地时区)。

## Webhook 设置(生产用)

1. 加载脚本 → 点击🔔建立警报:

* **Condition**:`Any alert() function call`
* **Options**:`Once per bar close`
* **Webhook URL**:填写你的接收地址(可带 `?token=...`)
* **Message**:可留空(脚本内部 `alert(payload)` 会发送 JSON)
2. 典型 JSON(字段以实际为准):

```json
{
"event": "step2_signal",
"symbol": "LULU",
"symbol_id": "NASDAQ:LULU",
"venue": "NASDAQ",
"bench": "SPY",
"sector": "XLY",
"ts_bar_close_ms": 1754524200000,
"ts_bar_close_local": "2025-06-06 10:30",
"price_close": 318.42,
"ret_4h_pct": -5.30,
"ret_8h_pct": -7.45,
"rel_mkt_pct": -4.90,
"rel_sec_pct": -3.80,
"pct_above_sma50_4h": 62.5,
"adv20_usd": 25500000
}
```

**对接建议**:用 `symbol + ts_bar_close_ms` 作为去重键;接收端快速返回 200,再异步处理并交给 AI。

## 使用与验证

* 可在任意分辨率图表使用——内部统一拉取 **240 分钟**与**日级**数据;
* **Bar Replay 不会发送真实 Webhook**,但会显示历史命中与“最近信号表”;测试接收端请用警报面板的 **Test**;
* 如需严格按 PT 计时,将图表时区设为 `America/Los_Angeles`。

## 常见问题

* **`ta.sum` 报错**:本版本已改为二值 `ta.sma(...,80)*100`;无需 `ta.sum`。
* **数字带下划线**:Pine 不支持 `20_000_000`,请用 `20000000` 或 `2e7`。
* **`syminfo.exchange`**:Pine v5 无此字段;脚本使用 `syminfo.prefix`(交易所前缀)。
* **提前出现“最近信号”**:已修为**上一根 4h 收盘**才记录与上报;表格与 Webhook 的时间均为上一根 4h 的收盘。

## 免责声明

仅用于筛选与研究,不构成投资建议。请结合你的“第3步新闻甄别 / 第4步执行与风控”共同决策。

— end —
릴리즈 노트
4h Relative Oversold Scanner · Webhook v3.3

Z-score + 1h RSI + 15m AVWAP A/B/C/D/E/F + Optional CVD Gate + Macro Circuit Breakers

What this script does

This scanner finds US equities that suddenly sell off on short-term news or sentiment, while the company’s fundamentals are assumed intact.
It emits one compact alert at the first qualifying 15-minute close and then plots a 15-minute anchored AVWAP with ±1/2/3σ bands to help you time entries on the rebound.

Scope constraints you can enforce: constituents of S&P 500, Nasdaq-100, or the Nasdaq Golden Dragon China index.

Why these signals

Fast detection on 15m: you want AI/news review to begin as soon as the event starts, not after the 4h candle ends.

Fixed depth vs. market/sector: true capitulations are deep relative to both the index and the stock’s peer group, not just in absolute terms.

Z-score context: guards against false positives during low-volatility regimes and provides regime awareness without replacing fixed depth rules.

Macro circuit breakers: if the whole tape is breaking (VIX spike or broad 16/32-bar drawdowns), stand down—most bounces fail in broad liquidations.

15m-anchored AVWAP: commonly used by liquidity providers to define “cost basis” after the event; the first recapture and subsequent pullbacks are high-quality entry zones.

Timeframe model

Signal detection runs on the 15-minute stream, including extended hours.

RSI filter runs on 1-hour data.

AVWAP and its bands are computed strictly in the 15-minute space via request.security, so results are stable no matter what chart timeframe you view.

Step 2 — Oversold signal (what must be true at the 15m bar close)

All conditions are evaluated on the preceding 16/32 fifteen-minute bars unless noted.

Fixed depth (always required)

4h depth: cumulative return over last 16×15m ≤ −4%

8h depth: cumulative return over last 32×15m ≤ −6%

Relative weakness (vs. market and sector)

Stock 4h return − Benchmark 4h return ≤ −3%

Stock 4h return − Sector 4h return ≤ −3%
Benchmarks are user-selectable (e.g., SPY/QQQ for market; XLK/XLF/XLY… or KWEB/CQQQ for sector).

New depth reference (v3.3 change)

Drop is measured against the lower of: previous RTH day’s VWAP or previous RTH day’s close.
Rationale: uses a realistic “yesterday value” that traders anchored to during the prior session.

1h momentum exhaustion

RSI(1h) < 30

Optional Z-score context (enabled does not replace fixed depth)

If enabled: Z(stock 4h) ≤ −1.5 AND Z(benchmark 4h) ≥ −1.0 AND Z(sector 4h) ≥ −1.0

Macro circuit breakers (any one trips → suppress the signal)
Defaults are editable in Inputs; suggested starts:

VIX spike: VIX 15m/1h change ≥ +8%

Market slide: Benchmark −2.0% (16 bars) or −3.0% (32 bars)

Sector slide: Sector −2.0% (16 bars) or −3.0% (32 bars)
Rationale: if the whole tape is in liquidation, avoid catching falling knives.

Optional CVD gate (if enabled)

15m CVD divergence or net-sell saturation detected around the event bar to confirm seller exhaustion.
You can toggle this on/off in Inputs.

Cooling and windows

Cooldown per symbol to avoid repeated alerts on the same cascade.

Entry windows cap: display at most the first three opportunities per entry type within one week of the signal.

Step 4 — Entries after the signal (AVWAP anchored at the signal’s 15m close)

The script pins an event anchor at the first qualifying 15m close, then draws AVWAP and ±1σ/±2σ/±3σ from that anchor, all computed on 15m data.

Entry models

A From ≤ −2σ, then close crosses up through −1σ (safer, higher win rate).

B From ≤ −1σ, then close recaptures AVWAP (good for faster reversals).

C Breaks −1σ, pullback holds near −1σ (with tolerance), then re-up.

D Volatility compression after the event, then AVWAP recapture.

E Tag −3σ, mean-revert back to −2σ and hold.

F Climbs from −3σ to −1σ without losing −2σ more than N bars (strong V-reversal).
You can enable/disable A–F individually. The panel shows which entries are active, and the chart pins up to three of each within one week of the event.

Optional CVD in entries (if the CVD gate is enabled)

Require CVD to improve or sell-pressure ratio to normalize before confirming A/B/C; throttle entries when buy-pressure spikes into resistance.

Alerts and webhook

Create a TradingView alert on this indicator, “Any alert() function call”.

Payload is intentionally minimal for downstream AI:
{ "event": "step2_15m", "symbol": "<TICKER>", "ts_15m_ms": <unix_ms> }
The anchor time is that same 15m close. Your processor can enrich with fundamentals/news.

Inputs at a glance

Benchmark and Sector tickers

Fixed depth thresholds for 16/32 fifteen-minute windows

Relative weakness thresholds vs. benchmark and sector

Z-score settings and enable switch

RSI(1h) threshold

Macro circuit breakers: VIX spike, market/sector drops

CVD gate toggle and sensitivity

Entry model toggles A–F, pullback tolerance, ATR compression limit

Cooldown, entry window length, and per-type max entries

Usage workflow

Run the scanner on a watchlist of filtered constituents (S&P 500 / NDX / Golden Dragon China).

On first 15m alert, let your AI triage whether the news is non-structural.

If allowed, use the anchored AVWAP bands to stage: A for conservative bounces, B/C for momentum recapture, D for compressed coils, E/F for extreme flush reversals.

Manage exits with AVWAP loss, band rejections, prior HVN/POC from volume profile, or time-based rules.

Notes and limitations

Extended hours are included for early detection; if you’d like RTH only, disable extended in Inputs.

Some brokers’ data feeds may label premarket differently; minor discrepancies in the very first alert bar are possible.

This is a scanner and entry framework, not a full risk engine; size and exit logic are left to the user.

Changelog highlights (v3.3)

Signals moved to 15m with extended hours; RSI filter moved to 1h.

Depth now references the lower of prior RTH VWAP vs. prior RTH close.

Added macro circuit breakers: VIX spike and market/sector fixed drawdowns.

Removed structure-health and MA50/200 position checks.

AVWAP computed in a dedicated 15m space for stability across chart timeframes; added ±3σ and new Entry E/F.

Optional CVD gate for both signal and entries.

Alert payload simplified to symbol + 15m timestamp for AI workflows.

Display limits: up to three A–F entries per cascade within one week; restored compact history panel.

Disclaimer
Markets carry risk. This tool is for research and execution support and does not constitute investment advice.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.