docs: add document

This commit is contained in:
Toh4iem9
2026-10-25 11:19:44 +01:00
parent 23dc90c65d
commit 22cdb88fa4
@@ -1,8 +1,8 @@
# Institutional Fractal Dimension Index Pro (Enterprise Ultra Edition v2.20)
# Institutional Fractal Dimension Index Pro (Enterprise Ultra Edition v2.40)
## 1. Executive Summary & Fractal Topology in Financial Markets
The **Institutional Fractal Dimension Index Pro (FDI_Pro)** is an advanced non-linear quantitative regime-detection engine engineered for MetaTrader 5 (Year 2026 Enterprise Edition). Rooted in the mathematical principles of Benoit Mandelbrot's fractal geometry and Carlos Ševčík's normalized waveform algorithm (1998), it quantifies the **topological complexity, persistence, and geometric roughness** of price trajectories.
The **Institutional Fractal Dimension Index Pro (FDI_Pro)** is an advanced non-linear quantitative regime-classification and persistence-detection engine developed for MetaTrader 5 (Year 2026 Enterprise Edition). Rooted in the mathematical principles of Benoit Mandelbrot's fractal geometry and Carlos Ševčík's normalized waveform algorithm (1998), it quantifies the **topological complexity, memory persistence, and geometric roughness** of price trajectories.
### The Topological Scale of Market Dimension ($D$)
@@ -43,7 +43,7 @@ The algorithm maps an arbitrary financial time series of length $N$ onto a norma
+-------------------------------------------------------------------------------+
| SEVCIK FRACTAL DIMENSION PIPELINE |
+-------------------------------------------------------------------------------+
Price Window: [P_{i-N+1} ... P_i] (Length N = 30)
Price Stream: P_t (Standard or Heikin Ashi via ENUM_APPLIED_PRICE_HA_ALL)
|
v
Unit Square Coordinate Normalization:
@@ -58,6 +58,14 @@ The algorithm maps an arbitrary financial time series of length $N$ onto a norma
Fractal Dimension Output (D):
FDI_NORMALIZED_BROWNIAN: D = 1.0 + ln(L) / ln(N - 1)
[Strictly Anchored: Flat Line = 1.00, Brownian Walk = 1.50, Chaos = 2.00]
|
+---------------------------------------+
| |
v v
+-----------------------------+ +-----------------------------+
| 3-Zone Activity Classifier | | Unified Signal MA Engine |
| (Blue, Gold, Crimson) | | (SMA, EMA, SMMA, LWMA...) |
+-----------------------------+ +-----------------------------+
```
@@ -74,19 +82,11 @@ $$L = \sum_{k=1}^{N-1} \sqrt{(\Delta x)^2 + (\Delta y_k)^2}$$
*ALU Optimization: The engine precalculates $(\Delta x)^2$ in `Init()` and replaces all runtime divisions with a single reciprocal multiplication: $\Delta y_k = \Delta P_k \cdot (1.0 / \text{Range}_t)$, achieving a 4x ALU pipelined speedup.*
### B. The Finite-Window Scaling Paradox & Brownian Normalization
### B. The Pure Brownian Normalization (`FDI_NORMALIZED_BROWNIAN`)
In Carlos Ševčík's original 1998 derivation, the formula was defined as:
$$D = 1.0 + \frac{\ln(L)}{\ln(2 \cdot (N - 1))}$$
In Carlos Ševčík's original 1998 formulation, the denominator included a factor of 2: $\ln(2(N-1))$. At small trading windows ($N = 30$), this suppressed the random walk value from $1.50$ down to $1.25$, causing conventional indicators to remain locked in the blue trend zone.
* **The Finite-Window Flaw:** Ševčík designed his formula for large datasets ($N = 1024, 2048$). At small trading windows ($N = 30$), the denominator $\ln(2(N-1)) = \ln(58) \approx 4.06$ is excessively large relative to the random walk path length ($L \approx 3.0$). Consequently, a pure random walk produced $D \approx 1.25 \dots 1.28$, completely failing to reach the theoretical $1.50$ baseline!
* **The Retail `+ln(2)` Hack:** Early retail coders attempted to fix this by arbitrarily adding $\ln(2)$ to the numerator:
$$D_{\text{retail}} = 1.0 + \frac{\ln(L) + \ln(2)}{\ln(2 \cdot (N - 1))}$$
While this shifted random walk close to $1.45$, it introduced an artificial $+0.17$ upward bias on straight lines ($L = 1.0 \implies D \approx 1.17$).
### The Solution: Pure Brownian Normalization (`FDI_NORMALIZED_BROWNIAN`)
In **v2.10+**, the engine incorporates the **Pure Brownian Normalized Scaling**:
`FDI_Pro` incorporates the **Pure Brownian Normalized Scaling**:
$$D = 1.0 + \frac{\ln(L)}{\ln(N - 1)}$$
* **Flat Straight Line ($L = 1.0$):** $\ln(1.0) = 0 \implies \mathbf{D \equiv 1.000}$ (Perfect Euclidean trend).
@@ -114,7 +114,32 @@ $$H = 2.0 - D$$
---
## 4. High-Performance 2026 MTF Fast-Path Architecture
## 4. Centralized `CFractalEngine` & Universal Price Pipeline
In accordance with Level 5 Enterprise Architecture conventions (Single Responsibility Principle & DRY), `CFDICalculator` embeds **`<MyIncludes\Fractal_Engine.mqh>`** as its single mathematical source of truth:
* All fractal dimension, unit-square path length, and Hurst exponent operations are centralized.
* Supports **14 price types natively** (`ENUM_APPLIED_PRICE_HA_ALL`), including 7 standard prices and 7 smoothed Heikin Ashi prices.
### Why Heikin Ashi Smoothing Enhances Fractal Analysis
On volatile crypto and index instruments, single-bar tick wicks artificially inflate the Euclidean path length $L$, falsely driving the fractal dimension toward chaos ($> 1.55$).
Selecting **`PRICE_HA_CLOSE`**, **`PRICE_HA_TYPICAL`**, or **`PRICE_HA_MEDIAN`** filters out isolated micro-wicks, measuring the authentic topological roughness of the underlying trend body.
---
## 5. Unified Signal Line Architecture (`MovingAverage_Engine.mqh`)
To quantify whether the market's fractal complexity is accelerating or decaying, `FDI_Pro` embeds the unified `CMovingAverageCalculator::CalculateOnArray()` engine, providing a high-contrast **Magenta Signal Line (`InpSignalType`)**:
* **VHF / FDI Momentum Rule:**
* When `FDI` falls below its Signal Line: Trend persistence is accelerating ($H$ is expanding).
* When `FDI` crosses above its Signal Line: Market is transitioning into random chop.
* **Supported Signal Types:** `EMA`, `SMA`, `SMMA` (Wilder), `LWMA`, `DEMA`, `TEMA`, and `VWMA`.
---
## 6. High-Performance 2026 MTF Fast-Path & Multi-Instance Protocol
When evaluating higher timeframe fractal dimensions (e.g., viewing H1 or H4 FDI on an M5 or M15 chart), traditional indicators freeze the terminal UI by executing tens of thousands of `iBarShift()` API calls.
@@ -137,10 +162,11 @@ Higher Timeframe (h_time[]): [HTF 0] ---> [HTF 1] ---> ... ---> [HTF 1,999]
* **Two-Pointer Linear Sweep:** Replaces 50,000 native API calls with $O(N)$ integer pointer increments. Historical synchronization latency drops from **$\approx 35.0 \text{ ms}$ to $\approx 0.08 \text{ ms}$ (350x speedup)**.
* **Live-Tick Isolated Fast-Path:** Intra-bar ticks update the forming HTF candle in RAM (`live_idx = g_htf_count - 1`), snapping instantly to the block start via $O(\log N)$ binary search (`ArrayBsearch`).
* **Zero-Heap Mandate:** All buffers, caches, and registers reside in persistent BSS arrays. **Zero bytes of heap allocation occur on live ticks.**
* **Multi-Instance Isolation (`InpInstanceID`):** Every instance on a chart generates a unique deterministic namespace (`FDI_%I64d_%s_%d_%d_`), completely preventing multi-indicator collisions.
---
## 5. Comprehensive Parameter Reference & Calibration Matrix
## 7. Comprehensive Parameter Reference & Calibration Matrix
### Input Settings
@@ -149,51 +175,34 @@ Higher Timeframe (h_time[]): [HTF 0] ---> [HTF 1] ---> ... ---> [HTF 1,999]
| `InpTimeframe` | `ENUM_TIMEFRAMES` | `PERIOD_CURRENT` | Calculation timeframe (Current or HTF). | Native $O(1)$ or Two-Pointer MTF. |
| `InpPeriod` | `int` | `30` | Analysis window ($N$, recommended: 20–50). | Governs curve sample size. |
| `InpMethod` | `ENUM_FDI_METHOD` | `FDI_NORMALIZED_BROWNIAN` | Mathematical scaling formulation. | Flagship mode: Brownian Normalization. |
| `InpPrice` | `ENUM_APPLIED_PRICE` | `PRICE_CLOSE` | Source price series. | Applied price feed. |
| `InpPriceSource` | `ENUM_APPLIED_PRICE_HA_ALL` | `PRICE_CLOSE_STD` | Price source (Standard / Heikin Ashi). | Full Heikin Ashi support. |
| `InpHistoryBars` | `int` | `1000` | Historical lookback limit (0 = Full Chart). | Eliminates cold-start terminal freezes. |
| `InpAutoThresholds` | `bool` | `true` | Auto-adapts thresholds to window $N$. | Guarantees balanced color distribution. |
| `InpLevelTrend` | `double` | `1.45` | Manual trend threshold (if Auto is false). | Upper boundary for DeepSkyBlue zone. |
| `InpLevelChop` | `double` | `1.55` | Manual chop threshold (if Auto is false). | Lower boundary for Crimson zone. |
| `InpVisualType` | `ENUM_FDI_VISUAL` | `VISUAL_FDI_HISTOGRAM` | Display mode (`VISUAL_FDI_LINE` or `VISUAL_FDI_HISTOGRAM`). | Toggles plot appearance. |
| `InpVisualType` | `ENUM_FDI_VISUAL` | `VISUAL_FDI_LINE` | Display mode (`VISUAL_FDI_LINE` or `VISUAL_FDI_HISTOGRAM`). | Toggles plot appearance. |
| `InpColorTrend` | `color` | `clrDeepSkyBlue` | Plot color for Persistent Trend ($D < 1.45$). | Native GPU plot buffer. |
| `InpColorRandom` | `color` | `clrGold` | Plot color for Random Walk ($1.45 \le D \le 1.55$). | Native GPU plot buffer. |
| `InpColorChop` | `color` | `clrCrimson` | Plot color for Anti-persistent Chop ($D > 1.55$). | Native GPU plot buffer. |
| `InpWidthPlot` | `int` | `2` | Main plot line / histogram width. | Visual thickness. |
| `InpShowSignal` | `bool` | `true` | Display Signal Line overlay. | Toggles Signal Line plot. |
| `InpSignalPeriod` | `int` | `9` | Signal Line exponential smoothing period. | Governs trend momentum in FDI. |
| `InpSignalPeriod` | `int` | `9` | Signal Line smoothing period. | Governs trend momentum in FDI. |
| `InpSignalType` | `ENUM_MA_TYPE` | `EMA` | Signal Line MA Method (SMA, EMA, etc.). | Unified Moving Average Engine. |
| `InpColorSignal` | `color` | `clrMagenta` | Universal high-contrast Signal Line color. | Highly visible on dark & light themes. |
| `InpWidthSignal` | `int` | `2` | Signal Line width. | Visual thickness. |
| `InpInstanceID` | `int` | `1` | Unique instance ID for multi-indicator setups. | Prevents chart namespace collisions. |
### Quantitative Calibration Matrix
| Trading Style | Asset Class | Base Chart | Target TF | FDI Period ($N$) | Calculation Method | Strategy Objective |
| :--- | :--- | :---: | :---: | :---: | :---: | :--- |
| **Micro-Scalping** | Indices / Majors FX | M1 / M5 | `PERIOD_CURRENT` | `20` | `FDI_NORMALIZED_BROWNIAN` | Fast detection of micro-trend persistence vs spread chop. |
| **Day Trading** | FX / Oil / Metals | M5 / M15 | M15 / H1 | `30` | `FDI_NORMALIZED_BROWNIAN` | Standard institutional calibration for session breakout filtering. |
| **Swing Trading** | Equities / Crypto | H1 / H4 | H4 / D1 | `40` | `FDI_NORMALIZED_BROWNIAN` | Filters multi-day consolidation noise on macro asset flows. |
| Trading Style | Asset Class | Base Chart | Target TF | FDI Period ($N$) | Calculation Method | Price Source | Strategy Objective |
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :--- |
| **Micro-Scalping** | Indices / Majors FX | M1 / M5 | `PERIOD_CURRENT` | `20` | `FDI_NORMALIZED_BROWNIAN` | `PRICE_MEDIAN_STD` | Fast detection of micro-trend persistence vs spread chop. |
| **Day Trading** | FX / Oil / Metals | M5 / M15 | M15 / H1 | `30` | `FDI_NORMALIZED_BROWNIAN` | `PRICE_CLOSE_STD` | Standard institutional calibration for session breakout filtering. |
| **Swing Structure** | Equities / Crypto | H1 / H4 | H4 / D1 | `40` | `FDI_NORMALIZED_BROWNIAN` | `PRICE_HA_CLOSE` | Filters multi-day consolidation noise on macro asset flows. |
---
## 6. Visual Interface Standards & High-Contrast Design
```text
Plot 0: [BufFDI ] ---> DRAW_COLOR_LINE / DRAW_COLOR_HISTOGRAM (Width 2)
- Color 0: clrDeepSkyBlue (Trend Regime)
- Color 1: clrGold (Equilibrium / Random Walk)
- Color 2: clrCrimson (Chaos / Mean-Reverting Chop)
Plot 1: [BufSignal] ---> DRAW_LINE (clrMagenta, Width 2)
- Universal high-contrast signal overlay.
- Distinctly visible on both Black and White chart templates.
```
* **Auto-Adaptive Levels:** When `InpAutoThresholds = true`, horizontal lines at $D_{\text{trend}}$, $1.50$, and $D_{\text{chop}}$ are dynamically injected into the subwindow based on the exact sample depth $N$.
---
## 7. Quantitative Trading Playbooks
## 8. Quantitative Synergy Playbooks & EA Integration Guide
### Playbook A: Persistent Trend Surfing ($D < 1.45$ + `KAMA_Bands_Pro`)
@@ -214,53 +223,29 @@ FDI Subwindow
```
1. **Setup:**
* Price breaks outside consolidation.
* `FDI_Pro` drops sharply below `1.45` and prints **Deep Sky Blue**.
* *Interpretation:* The Hurst exponent has expanded above $H > 0.55$. Price increments possess strong positive autocorrelation (persistence).
2. **Execution Trigger:**
* Enter in the direction of the breakout.
* Allow pullbacks to retest the $+1.0\sigma$ band of `KAMA_Bands_Pro`. As long as $D < 1.45$, hold the trade with wide trailing stops.
3. **Exit:** Exit or take partial profits when `BufFDI` climbs back above `1.50` (trend persistence has decayed back into random walk equilibrium).
1. **Setup:** Price breaks outside consolidation. `FDI_Pro` drops sharply below `1.45` and prints **Deep Sky Blue**.
2. **Interpretation:** Hurst exponent has expanded above $H > 0.55$. Price increments possess strong positive autocorrelation (persistence).
3. **Execution:** Enter in the direction of the breakout. Hold position as long as $D < 1.45$. Exit when `BufFDI` crosses back above $1.50$.
---
### Playbook B: Anti-Persistent Mean-Reversion Scalp ($D > 1.55$ at $\pm 3\sigma$)
1. **Setup:**
* Price spikes into the extreme outer $\pm 3.0\sigma$ band of `VWAP_Bands_Pro` or `KAMA_Bands_Pro`.
* `FDI_Pro` surges above `1.55` and prints **Crimson Red**.
* *Interpretation:* $H < 0.45$. The market is severely anti-persistent. A space-filling jagged reversal is mathematically probable.
2. **Execution Trigger:**
* Wait for a wick rejection candle at the $\pm 3\sigma$ band.
* **FADE:** Enter Short (if at upper band) or Long (if at lower band) targeting the mean.
* **Stop Loss:** Strict tight stop (10 ticks). In anti-persistent regimes, reversals occur immediately; if price continues running, an institutional regime shift is occurring.
1. **Setup:** Price spikes into the extreme outer $\pm 3.0\sigma$ band of `VWAP_Bands_Pro` or `KAMA_Bands_Pro`.
2. **FDI Audit:** `FDI_Pro` surges above `1.55` and prints **Crimson Red** ($H < 0.45$).
3. **Execution:** The market is severely anti-persistent. A space-filling reversal is mathematically imminent. Fade the move targeting the mean with a strict tight stop.
---
### Playbook C: The Dual-Complexity Meta-Filter (`FDI_Pro` + `Entropy_Pro`)
### Example MQL5 EA Integration Snippet
| Regime Metric | `Entropy_Pro` (SampEn) | `FDI_Pro` (Fractal Dimension) | Market State & Strategic Alignment |
| :---: | :---: | :---: | :--- |
| **Low / Low** | $< 0.80$ (Blue) | $< 1.45$ (Blue) | **PRISTINE SUPER-TREND.** Maximum geometric & phase space order. Heavy trend positioning permitted. |
| **Low / High** | $< 0.80$ (Blue) | $> 1.55$ (Red) | **COILED SQUEEZE.** Price is compressing inside a narrow space-filling channel. Impending explosive breakout. |
| **High / High** | $> 1.30$ (Red) | $> 1.55$ (Red) | **TOTAL MARKET TOXICITY.** High entropy + high fractal roughness. **100% Cash / No Trading.** |
---
## 8. Developer Integration & Expert Advisor Guide
The indicator exposes its visual buffers directly to MetaTrader 5 Expert Advisors (EAs) via the native `iCustom()` API:
### Buffer Index Map
The indicator exposes its visual buffers directly to MetaTrader 5 Expert Advisors (EAs) via `iCustom()`:
| Buffer Index | Identifier | Description | Range / Output |
| :---: | :--- | :--- | :--- |
| `0` | `BufFDI` | Raw Fractal Dimension Index ($D$). | Continuous double ($1.0 \dots 2.0$). |
| `1` | `BufColor` | Active Color Index. | `0.0` (Blue: Trend), `1.0` (Gold: Random Walk), `2.0` (Red: Chop). |
| `2` | `BufSignal` | Signal Line (Exponential Moving Average of FDI). | Continuous positive double. |
### Example MQL5 EA Integration Snippet
| `2` | `BufSignal` | Signal Line (Unified Moving Average). | Continuous positive double. |
```mql5
//+------------------------------------------------------------------+
@@ -275,7 +260,7 @@ int OnInit()
PERIOD_CURRENT, // Timeframe
30, // Analysis Window (N)
FDI_NORMALIZED_BROWNIAN, // Brownian Normalization
PRICE_CLOSE, // Price Source
PRICE_CLOSE_STD, // Price Source
1000, // History Bars Limit
true, // Auto-Adaptive Thresholds
1.45, // Manual Trend Threshold
@@ -287,9 +272,11 @@ int OnInit()
2, // Plot Width
true, // Show Signal Line
9, // Signal Period
EMA, // Signal MA Type (ENUM_MA_TYPE)
clrMagenta, // Signal Color
STYLE_SOLID, // Signal Style
2); // Signal Width
2, // Signal Width
1); // Instance ID
if(h_fdi == INVALID_HANDLE)
{
@@ -301,19 +288,21 @@ int OnInit()
void OnTick()
{
double fdi[1], col[1];
double fdi[1], col[1], sig[1];
// Read bar index 1 (closed bar) to guarantee non-repainting execution
if(CopyBuffer(h_fdi, 0, 1, 1, fdi) <= 0 ||
CopyBuffer(h_fdi, 1, 1, 1, col) <= 0)
CopyBuffer(h_fdi, 1, 1, 1, col) <= 0 ||
CopyBuffer(h_fdi, 2, 1, 1, sig) <= 0)
return;
double fdi_value = fdi[0];
double regime_color = col[0]; // 0=Trend, 1=Random Walk, 2=Chop
double signal_value = sig[0];
// REGIME 1: PERSISTENT TREND REGIME (Deep Sky Blue)
if(regime_color == 0.0)
if(regime_color == 0.0 && fdi_value < signal_value)
{
// Hurst Exponent H > 0.55! Enable trend-following and momentum breakout robots.
// Hurst Exponent H > 0.55 and persistence is accelerating! Enable trend models.
EnableTrendStrategy(true);
EnableMeanReversionStrategy(false);
}
@@ -327,7 +316,7 @@ void OnTick()
// REGIME 2: RANDOM WALK EQUILIBRIUM (Gold)
else
{
// Uncorrelated noise. Disable aggressive trading.
// Uncorrelated noise. Stand down.
EnableTrendStrategy(false);
EnableMeanReversionStrategy(false);
}