OPEN-SOURCE SCRIPT
Cập nhật Compression Clock (Axiom Multi-TF Adaptive)

**Compression Clock (Axiom Multi-TF Adaptive) — Volatility Regime & State Age**
---
### **Description**
#### **Overview**
The **Compression Clock** is a non-directional volatility regime indicator based on the **Axiom quantitative research framework**. Instead of attempting to forecast market direction, it isolates the temporal dimension (**WHEN**) by measuring the duration and depth of volatility compression across any resolution.
Markets do not transition from quiet to expansion instantaneously; they exhibit a survival-rate decay where prolonged low-volatility states exponentially elevate the baseline probability of large physical displacement. The Compression Clock standardizes this process by normalizing rolling volatility and volume percentiles against a physical-time benchmark.
---
#### **Mathematical & Architectural Core**
1. **Dual-Feature Quiet Filter**:
* Evaluates rolling True Range ($\text{ATR}_{24}$) and Traded Volume ($\text{SMA}_{24}$) scaled against an intraday 24-hour physical window:
$$\text{ATR}_{\text{rolling}} = \text{SMA}(\text{TR}, N_{\text{bars}}), \quad \text{Vol}_{\text{rolling}} = \text{SMA}(\text{Volume}, N_{\text{bars}})$$
* Computes the rolling percentile rank of both features across a rolling 180-day baseline distribution.
* A bar qualifies as **Quiet** if and only if both features sit simultaneously in the lower tercile:
$$\text{Quiet}_t = \mathbb{I}\left(\text{Rank}(\text{ATR}_t) \le 33.33\%\right) \land \mathbb{I}\left(\text{Rank}(\text{Vol}_t) \le 33.33\%\right)$$
2. **Physical-Time Normalization**:
* TradingView indicators often suffer from timescale distortion when hardcoding bar-based periods across multiple resolutions.
* This script dynamically translates resolution minutes ($M_{\text{tf}}$) into actual **physical hours**. Whether applied to a 5-minute, 30-minute, or 4-hour chart, the Y-axis consistently represents **elapsed physical hours of continuous compression**.
3. **Regime State Categorization**:
* **S0 (ACTIVE)**: Market is expanding or fluctuating outside the quiet threshold. Compression age resets to 0.
* **S1 (QUIET, < 24 Hours)**: Early-stage compression. Natural volatility dampening without statistical hazard elevation.
* **S2 (MATURE, 24 – 72 Hours)**: Statistically mature compression. Historical survival analysis indicates a significant elevation in large-displacement probability.
* **S3 (DEEP, > 72 Hours)**: Extreme volatility exhaustion. Persistent absence of dispersion indicating imminent volatility expansion.
---
#### **How to Use (Methodological Discipline)**
* **Decoupled Architecture**:
* The Clock dictates **WHEN** (volatility environment), not **WHAT** (direction) or **HOW** (execution).
* Never treat an S2/S3 state as a directional trade signal. A compression state is directionally agnostic—it warns of imminent displacement hazard, but the direction must be governed by external momentum or structural acceptance/rejection models.
* **Multi-Timeframe Scope**:
* Low-scale compression (e.g., 5m/15m entering S3) reflects localized intraday order book exhaustion. It does **not** override a higher-timeframe S0 state. For macro regime filtering, monitor higher physical resolutions (such as 4H).
* **Buffer Safety**:
* Includes a built-in 4,900-bar memory clamp to prevent buffer overflow exceptions on ultra-low timeframes while maintaining valid causal percentile rankings.
---
#### **Inputs**
* **Rolling Feature Duration (Hours)**: Physical length of the short-term smoothing window (Default: 24h).
* **Lookback Days (Days)**: Historical distribution window for empirical percentile rankings (Default: 180 days).
* **Quantile Rank Threshold (%)**: Cutoff for the quiet regime (Default: 33.333% — bottom tercile).
---
### **Description**
#### **Overview**
The **Compression Clock** is a non-directional volatility regime indicator based on the **Axiom quantitative research framework**. Instead of attempting to forecast market direction, it isolates the temporal dimension (**WHEN**) by measuring the duration and depth of volatility compression across any resolution.
Markets do not transition from quiet to expansion instantaneously; they exhibit a survival-rate decay where prolonged low-volatility states exponentially elevate the baseline probability of large physical displacement. The Compression Clock standardizes this process by normalizing rolling volatility and volume percentiles against a physical-time benchmark.
---
#### **Mathematical & Architectural Core**
1. **Dual-Feature Quiet Filter**:
* Evaluates rolling True Range ($\text{ATR}_{24}$) and Traded Volume ($\text{SMA}_{24}$) scaled against an intraday 24-hour physical window:
$$\text{ATR}_{\text{rolling}} = \text{SMA}(\text{TR}, N_{\text{bars}}), \quad \text{Vol}_{\text{rolling}} = \text{SMA}(\text{Volume}, N_{\text{bars}})$$
* Computes the rolling percentile rank of both features across a rolling 180-day baseline distribution.
* A bar qualifies as **Quiet** if and only if both features sit simultaneously in the lower tercile:
$$\text{Quiet}_t = \mathbb{I}\left(\text{Rank}(\text{ATR}_t) \le 33.33\%\right) \land \mathbb{I}\left(\text{Rank}(\text{Vol}_t) \le 33.33\%\right)$$
2. **Physical-Time Normalization**:
* TradingView indicators often suffer from timescale distortion when hardcoding bar-based periods across multiple resolutions.
* This script dynamically translates resolution minutes ($M_{\text{tf}}$) into actual **physical hours**. Whether applied to a 5-minute, 30-minute, or 4-hour chart, the Y-axis consistently represents **elapsed physical hours of continuous compression**.
3. **Regime State Categorization**:
* **S0 (ACTIVE)**: Market is expanding or fluctuating outside the quiet threshold. Compression age resets to 0.
* **S1 (QUIET, < 24 Hours)**: Early-stage compression. Natural volatility dampening without statistical hazard elevation.
* **S2 (MATURE, 24 – 72 Hours)**: Statistically mature compression. Historical survival analysis indicates a significant elevation in large-displacement probability.
* **S3 (DEEP, > 72 Hours)**: Extreme volatility exhaustion. Persistent absence of dispersion indicating imminent volatility expansion.
---
#### **How to Use (Methodological Discipline)**
* **Decoupled Architecture**:
* The Clock dictates **WHEN** (volatility environment), not **WHAT** (direction) or **HOW** (execution).
* Never treat an S2/S3 state as a directional trade signal. A compression state is directionally agnostic—it warns of imminent displacement hazard, but the direction must be governed by external momentum or structural acceptance/rejection models.
* **Multi-Timeframe Scope**:
* Low-scale compression (e.g., 5m/15m entering S3) reflects localized intraday order book exhaustion. It does **not** override a higher-timeframe S0 state. For macro regime filtering, monitor higher physical resolutions (such as 4H).
* **Buffer Safety**:
* Includes a built-in 4,900-bar memory clamp to prevent buffer overflow exceptions on ultra-low timeframes while maintaining valid causal percentile rankings.
---
#### **Inputs**
* **Rolling Feature Duration (Hours)**: Physical length of the short-term smoothing window (Default: 24h).
* **Lookback Days (Days)**: Historical distribution window for empirical percentile rankings (Default: 180 days).
* **Quantile Rank Threshold (%)**: Cutoff for the quiet regime (Default: 33.333% — bottom tercile).
Phát hành các Ghi chú
update displayMã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.