OPEN-SOURCE SCRIPT
Bayesian Liquidity Pain & Gain [Instit. Vol Weighted]

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.
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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。