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