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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。