OPEN-SOURCE SCRIPT

Waterfall Risk Composite

216
Waterfall Risk Composite (WRC)
The Waterfall Risk Composite is a quantitative short-side risk scoring system that detects the structural conditions that precede cascading selloff events — what traders call a "waterfall." Rather than identifying entry points, it measures how dangerous a stock's current environment is across three independent dimensions, combining them into a single 0–100 score.
What is a Waterfall Event?

A waterfall is a rapid, cascading price decline where selling pressure overwhelms buyers across multiple sessions. These events don't appear randomly — they are typically preceded by months of distribution, deteriorating relative strength, a collapsing MA structure, and expanding downside volatility. The WRC is designed to quantify exactly those preconditions.

How the Score is Built
The composite draws from three sub-scores, each capturing a different dimension of bearish risk:
1. Distribution Phase (max 35 pts)

Measures how aggressively a stock is being distributed relative to its benchmark. Inputs include the slope and persistence of relative strength (RS) vs XJO or SPY, the rolling up/down volume ratio over 20 sessions, and how far price has corrected from its 52-week high. A stock that has been underperforming its index for months, with more volume on down days than up days, and sitting 30–40% off its highs, will score near the maximum here.
2. Momentum Decay (max 40 pts)

Scores the structural deterioration of price momentum. This block carries the highest weighting because entrenched bear trends are the most reliable precondition for waterfall events. It measures the fast/slow EMA ratio slope (MOMO), the full bearish ordering of the 10/21/50/200 EMA stack (death cross zone scores maximum), how far and for how long price has been below the 200 EMA, and the number of consecutive days price has spent below the 40 EMA. A stock with a full bear MA stack, 150+ days below its 40 EMA, and deeply extended below its 200 EMA can score 40/40 on this block alone.
3. Volatility Stress (max 25 pts)

Detects volatility regime shifts and directional pressure. Scores the ratio of fast to slow ATR (expanding vol = stress), the proportion of ATR occurring on red candles vs green (asymmetric downside vol), and large red candles relative to the 20-day average body size — particularly when they break below a recent swing low, signalling acceleration.

Trend Gates — Soft Multiplier System

Three structural conditions act as gates that scale the final score:

Close below the 10-period Monthly MA
5 EMA below 10 EMA (daily)
Close below 40 EMA (daily)

Unlike a hard on/off switch, gates apply a proportional multiplier: all three passing = full score, two passing = 75%, one passing = 40%, none passing = score blocked entirely. This means a deeply bearish stock with a brief EMA cross-back won't suddenly drop to zero — the underlying deterioration is still reflected.

Settings

All key parameters are adjustable — RS lookback, volume window, ATR periods, gate EMA lengths, monthly MA length, alert thresholds, and table position. The indicator works on daily timeframes and above.
Alerts

Three alert conditions are included: Waterfall threshold crossed, Elevated threshold crossed, and risk declining back below Elevated.

Any ideas let me know. It's good but can be better.

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.