OPEN-SOURCE SCRIPT

Bayesian Liquidity Pain & Gain [Instit. Vol Weighted]

73
Bayesian Liquidity Pain & Gain Indicator
Stop guessing where support and resistance are.
The Bayesian Liquidity Pain & Gain indicator moves beyond arbitrary lines and raw price action. It quantifies Institutional Intent by calculating the exact price levels where large volume has been accumulated and visualizes the "Pain" (stress) those participants feel when the market moves against them.

The Logic: Quantified Institutional Stress
Institutions don't trade single candles; they accumulate positions over time. This indicator tracks their Volume-Weighted Average Cost Basis to answer two critical questions:
Where did they enter? (The Cost Basis Lines)
Are they underwater? (The Pain Clouds)
By normalizing price distance using volatility (ATR) and statistical deviation (Z-Score), we filter out noise and only highlight zones where "Smart Money" is statistically forced to defend their positions or capitulate.

How to Read the Chart

1. The Cost Basis Lines (Anchors)

• 🟢 Green Line (Buyer Cost Basis): The average price where institutions accumulated long positions. This acts as dynamic Support.

• 🔴 Red Line (Seller Cost Basis): The average price where institutions accumulated short positions. This acts as dynamic Resistance.
2. The Pain Clouds (Signals)
When price moves significantly away from the cost basis (Z-Score > 2.0), "Clouds" appear to visualize the PnL status of the participants:

• 🔴 Red Cloud (Buyer Pain): Price is below the buyer's entry. Buyers are losing money (in the red). This creates a "Discount" zone where they may defend support.

• 🟢 Green Cloud (Seller Pain): Price is above the seller's entry. Sellers are losing money (shorts are squeezed). This indicates strong bullish momentum.
3. The Multi-Timeframe Dashboard

A real-time HUD showing the Z-Score status across 4 timeframes (1m, 5m, 15m, 1h):
• 🟢 Green: Profitable/Neutral (Trend Continuation)
• 🟠 Orange: Warning (Pressure Building)
• 🔴 Red: Critical Pain (High Probability Reversal)

Trading Strategies
Setup 1: The Defensive Bounce (Long)
Context: Price drops into a 🔴 Red Cloud (Buyer Pain).
Trigger: Price touches the 🟢 Green Line (Buyer Cost Basis) and shows a rejection wick.
Logic: Institutional buyers defend their cost basis to avoid realizing losses.

Setup 2: The Short Squeeze (Momentum)
Context: Price rallies into a 🟢 Green Cloud (Seller Pain).
Trigger: Price holds above the 🔴 Red Line (Seller Cost Basis).
Logic: Short sellers are trapped and forced to buy back (cover), fueling the rally.

Fractal Alignment:
For high-conviction trades, wait for the Dashboard to show "Pain" signals on both the 1h (Anchor) and 5m (Trigger) timeframes simultaneously.

Settings
Memory Length (Default 144): The lookback period for the institutional cost basis. Increase for swing trading, decrease for scalping.
Sigma Threshold (Default 2.0): The statistical confidence level for "Pain". Higher values = fewer, stronger signals.
Volume Amp: When enabled, high volume amplifies the pain signal, giving more weight to institutional footprints.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.