OPEN-SOURCE SCRIPT
Advanced Fear & Greed Cycle (Quant Model)

## Overview
The **Advanced Fear & Greed Cycle (Quant Model) v6** is a pure quantitative oscillator designed to decode market sentiment by measuring the architectural divergence between smart money accumulation and retail distribution. Fully upgraded to Pine Script v6, this script addresses standard oscillator limitations by implementing dynamic time-frequency normalization ($0-100$ fixed scale).
Unlike standard sentiment proxies, this model filters out price-action noise by isolating volume flows, directional volatility, and mean-reversion extensions simultaneously.
---
## Mathematical Architecture & Core Engines
### 1. Directional Volatility Engine
Standard models treat volatility expansions as pure panic. This algorithm isolates **Directional Volatility**:
- A 14-period Average True Range (ATR) is mathematically normalized over a dynamic 90-day rolling quarter (`lookback`).
- **Trend Filter:** Volatility is converted into the `vol_fear` metric **only** if the closing price is below its 14-period Simple Moving Average (`is_descending`). Upside expansions (bullish breakouts) are correctly filtered out to prevent false panic readings.
### 2. Normalized Volume & Flow Sentiment
Liquidity and order-flow tracking are computed via a three-layered matrix:
- Normalized Volume spikes relative to the quarterly window.
- Inside-candle Selling Pressure (
HIGH - Close$ versus the overall candle range).
- A normalized On-Balance Volume (OBV) structure to track mathematical capital inflows and outflows.
### 3. Boundary-Proof Macro Extension (Mayer Proxy)
To track cyclical overextensions, the script calculates the asset's percentage distance from its long-term moving average (SMA 200 on Daily, SMA 40 on Weekly charts).
To solve the scale break-out issue (where different assets experience wildly different percentage extensions), a **MinMax Normalization** is applied. This compresses the structural extension into a bound $0-100\%$ scale (`extension_norm`) based on the rolling quarter's extremes.
---
## The Greed Score Synthesizer
The final plotting line is the **Greed Score**, a mathematically symmetric index calculated as:
$$\text{Greed Score} = \frac{(100 - \text{Fear Index}) + \text{Extension Norm}}{2}$$
This creates a fixed-bound oscillator ($0$ to $100$) that charts three distinct market phases:
- 🟢 **INSTITUTIONAL ACCUMULATION (Green Zone / < 20):** High systemic fear combined with compressed macro price extensions (< 25%). Smart money absorbs panicking retail order flow near historical value areas.
- ⚪ **NEUTRAL REGIME (Gray Line):** Symmetrical equilibrium where supply and demand are balanced.
- 🔴 **RETAIL FOMO / BUBBLE (Red Zone / > 80):** Zero systemic fear combined with extreme quarterly price overextensions. Retail traders buying the top driven by euphoria, highlighting distribution blocks.
---
## Display Dashboard & Custom Parameters
The top-right informational panel provides real-time diagnostic outputs of the quantitative data (Current Cycle State, Exact Greed Score, and Normalized Extension %). Traders can adjust the `Soglia Bolla Normalizzata` input to calibrate the macro-exhaustion scanner to specific asset classes (Equities, Forex, or Cryptocurrencies).
---
Disclaimer: This tool calculates mathematical probabilities based on normalized historical structures. It does not provide definitive buy/sell signals or financial advice. Always integrate sound risk management protocols.
The **Advanced Fear & Greed Cycle (Quant Model) v6** is a pure quantitative oscillator designed to decode market sentiment by measuring the architectural divergence between smart money accumulation and retail distribution. Fully upgraded to Pine Script v6, this script addresses standard oscillator limitations by implementing dynamic time-frequency normalization ($0-100$ fixed scale).
Unlike standard sentiment proxies, this model filters out price-action noise by isolating volume flows, directional volatility, and mean-reversion extensions simultaneously.
---
## Mathematical Architecture & Core Engines
### 1. Directional Volatility Engine
Standard models treat volatility expansions as pure panic. This algorithm isolates **Directional Volatility**:
- A 14-period Average True Range (ATR) is mathematically normalized over a dynamic 90-day rolling quarter (`lookback`).
- **Trend Filter:** Volatility is converted into the `vol_fear` metric **only** if the closing price is below its 14-period Simple Moving Average (`is_descending`). Upside expansions (bullish breakouts) are correctly filtered out to prevent false panic readings.
### 2. Normalized Volume & Flow Sentiment
Liquidity and order-flow tracking are computed via a three-layered matrix:
- Normalized Volume spikes relative to the quarterly window.
- Inside-candle Selling Pressure (
- A normalized On-Balance Volume (OBV) structure to track mathematical capital inflows and outflows.
### 3. Boundary-Proof Macro Extension (Mayer Proxy)
To track cyclical overextensions, the script calculates the asset's percentage distance from its long-term moving average (SMA 200 on Daily, SMA 40 on Weekly charts).
To solve the scale break-out issue (where different assets experience wildly different percentage extensions), a **MinMax Normalization** is applied. This compresses the structural extension into a bound $0-100\%$ scale (`extension_norm`) based on the rolling quarter's extremes.
---
## The Greed Score Synthesizer
The final plotting line is the **Greed Score**, a mathematically symmetric index calculated as:
$$\text{Greed Score} = \frac{(100 - \text{Fear Index}) + \text{Extension Norm}}{2}$$
This creates a fixed-bound oscillator ($0$ to $100$) that charts three distinct market phases:
- 🟢 **INSTITUTIONAL ACCUMULATION (Green Zone / < 20):** High systemic fear combined with compressed macro price extensions (< 25%). Smart money absorbs panicking retail order flow near historical value areas.
- ⚪ **NEUTRAL REGIME (Gray Line):** Symmetrical equilibrium where supply and demand are balanced.
- 🔴 **RETAIL FOMO / BUBBLE (Red Zone / > 80):** Zero systemic fear combined with extreme quarterly price overextensions. Retail traders buying the top driven by euphoria, highlighting distribution blocks.
---
## Display Dashboard & Custom Parameters
The top-right informational panel provides real-time diagnostic outputs of the quantitative data (Current Cycle State, Exact Greed Score, and Normalized Extension %). Traders can adjust the `Soglia Bolla Normalizzata` input to calibrate the macro-exhaustion scanner to specific asset classes (Equities, Forex, or Cryptocurrencies).
---
Disclaimer: This tool calculates mathematical probabilities based on normalized historical structures. It does not provide definitive buy/sell signals or financial advice. Always integrate sound risk management protocols.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.