OPEN-SOURCE SCRIPT
Waterfall Risk Composite

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.
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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.