OPEN-SOURCE SCRIPT
Dresteghamat:Adaptive Multi-TF Decision Engine

**Dresteghamat: Adaptive Multi-Timeframe Decision Engine**
This open-source indicator is an algorithmic decision-support system designed to filter market noise by quantifying three core market dimensions: **Regime**, **Direction**, and **Exhaustion**.
**⚠️ Technical Note on Originality:**
This script solves the "Timeframe Irrelevance" problem found in standard dashboards. Instead of using static HTF references, it implements a custom **"Adaptive Context Engine"** (see lines 245-270 in source code). It calculates the user's current `timeframe.multiplier` and dynamically maps the mathematically relevant Higher Timeframes.
* *Innovation:* A 5m chart automatically weights 15m/1H structure, whereas a 1H chart weights 4H/Daily structure. This dynamic logic is proprietary and ensures contextual accuracy.
---
### 🛠️ Logic & Calculation Methodology
The script does not simply overlay indicators. It processes raw market data through a **Weighted Scoring Engine** (lines 275-285) to output a unified market state.
**1. Regime Identification (Volatility Normalized)**
We calculate a custom "Volatility Ratio" to distinguish Trend vs. Range regimes.
* **Logic:** `Range / Smoothed_ATR`.
* **Function:** If Ratio > 2.0, the market is in Expansion (Trend). If < 1.2, it is in Compression (Range). This normalizes volatility across assets (Crypto/Forex/Stocks).
**2. Directional Bias (Composite Metric)**
Direction is calculated via a voting system of three sub-components (lines 80-130):
* **Structural Pivots:** Detects Swing Highs/Lows using a 25-bar lookback to define market structure.
* **Cumulative Body Delta:** Tracks the net buying/selling pressure within candle bodies.
* **Micro-Flow:** A short-term (5-bar) momentum filter to detect immediate order flow shifts.
**3. Exhaustion Model (Risk Management)**
The script prevents late entries by calculating an "Exhaustion Score" (lines 150-200). It aggregates:
* **VRSD (Volatility Regime Shift):** Detects when volatility expands > 2 standard deviations (Mean Reversion risk).
* **Volume Decay (VEFF):** Identifies Divergence where price makes new highs on declining Volume MA.
* **RSI/Impulse Divergence:** Standard momentum divergence logic.
**4. The Decision Output (MODE)**
The dashboard renders a final signal based on a hierarchical algorithm:
* **BUY/SELL ONLY:** Triggered when Current Momentum aligns with the Dynamically Selected HTF Structure AND the Exhaustion Score is low.
* **PULLBACK:** Triggered when HTF Structure is bullish, but Current Momentum is bearish (indicating a corrective phase).
* **HTF EXHAUST:** Overrides signals when the Higher Timeframe metrics hit extreme levels.
* **WAIT:** Default state during Range Regimes or conflicting signals.
---
### 📊 Usage Guide
1. Apply to chart (Auto-adapts to any timeframe).
2. **Status Column:** Shows the raw health of the trend (Strong/Weakening/Exhausted).
3. **MODE Column:** Displays the final actionable bias based on the scoring algorithm.
**Disclaimer:** This tool provides statistical analysis based on historical data. It does not guarantee future results.
This open-source indicator is an algorithmic decision-support system designed to filter market noise by quantifying three core market dimensions: **Regime**, **Direction**, and **Exhaustion**.
**⚠️ Technical Note on Originality:**
This script solves the "Timeframe Irrelevance" problem found in standard dashboards. Instead of using static HTF references, it implements a custom **"Adaptive Context Engine"** (see lines 245-270 in source code). It calculates the user's current `timeframe.multiplier` and dynamically maps the mathematically relevant Higher Timeframes.
* *Innovation:* A 5m chart automatically weights 15m/1H structure, whereas a 1H chart weights 4H/Daily structure. This dynamic logic is proprietary and ensures contextual accuracy.
---
### 🛠️ Logic & Calculation Methodology
The script does not simply overlay indicators. It processes raw market data through a **Weighted Scoring Engine** (lines 275-285) to output a unified market state.
**1. Regime Identification (Volatility Normalized)**
We calculate a custom "Volatility Ratio" to distinguish Trend vs. Range regimes.
* **Logic:** `Range / Smoothed_ATR`.
* **Function:** If Ratio > 2.0, the market is in Expansion (Trend). If < 1.2, it is in Compression (Range). This normalizes volatility across assets (Crypto/Forex/Stocks).
**2. Directional Bias (Composite Metric)**
Direction is calculated via a voting system of three sub-components (lines 80-130):
* **Structural Pivots:** Detects Swing Highs/Lows using a 25-bar lookback to define market structure.
* **Cumulative Body Delta:** Tracks the net buying/selling pressure within candle bodies.
* **Micro-Flow:** A short-term (5-bar) momentum filter to detect immediate order flow shifts.
**3. Exhaustion Model (Risk Management)**
The script prevents late entries by calculating an "Exhaustion Score" (lines 150-200). It aggregates:
* **VRSD (Volatility Regime Shift):** Detects when volatility expands > 2 standard deviations (Mean Reversion risk).
* **Volume Decay (VEFF):** Identifies Divergence where price makes new highs on declining Volume MA.
* **RSI/Impulse Divergence:** Standard momentum divergence logic.
**4. The Decision Output (MODE)**
The dashboard renders a final signal based on a hierarchical algorithm:
* **BUY/SELL ONLY:** Triggered when Current Momentum aligns with the Dynamically Selected HTF Structure AND the Exhaustion Score is low.
* **PULLBACK:** Triggered when HTF Structure is bullish, but Current Momentum is bearish (indicating a corrective phase).
* **HTF EXHAUST:** Overrides signals when the Higher Timeframe metrics hit extreme levels.
* **WAIT:** Default state during Range Regimes or conflicting signals.
---
### 📊 Usage Guide
1. Apply to chart (Auto-adapts to any timeframe).
2. **Status Column:** Shows the raw health of the trend (Strong/Weakening/Exhausted).
3. **MODE Column:** Displays the final actionable bias based on the scoring algorithm.
**Disclaimer:** This tool provides statistical analysis based on historical data. It does not guarantee future results.
开源脚本
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
开源脚本
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.