Files
mql5/Indicators/MyIndicators/DSS_Bressert_Pro_Documentation.md
T

367 lines
20 KiB
Markdown
Raw Normal View History

2026-10-03 17:24:17 +02:00
# Double Smoothed Stochastic (DSS) Bressert Pro (v3.20)
Walter Bressert's Canonical Stochastic-of-Stochastic Cycle Engine with Decoupled Dual Smoothings & Zero-Lag MTF Fast-Path
---
## 1. Summary (Introduction)
**DSS Bressert Pro (v3.20)** is an institutional-grade cycle-timing momentum oscillator implementing Walter Bressert's renowned **Double Smoothed Stochastic (DSS)**.
While William Blau's Double Smoothed Stochastic smooths the price distance ($C - LL$) and range ($HH - LL$) independently prior to division, **Walter Bressert's formulation applies Stochastic Normalization twice sequentially (Stochastic-of-Stochastic)**:
1. First, it computes a standard Stochastic Fast %K across raw price.
2. Second, it smooths this Fast %K into an intermediate curve ($Y$).
3. Third, **it applies the Stochastic normalization directly onto the smoothed $Y$ curve**, evaluating where the smoothed momentum sits relative to its own highest high and lowest low.
4. Fourth, it smooths this second-stage stochastic curve into the final **DSS Bressert** line.
This recursive normalization creates an extraordinarily clean, bounded (0 to 100) oscillator with distinct, sharp **V-shaped cycle inflection pivots** at extremes ($<10$ and $>90$), completely eliminating the jittery whipsaws of traditional stochastic indicators while providing instantaneous trend reversal identification.
```text
┌────────────────────────────────────────────────────────────────────────┐
│ THE TWO DOUBLE SMOOTHED PARADIGMS │
├────────────────────────────────────────────────────────────────────────┤
│ │
│ BLAU'S DSS: │
│ [ Price Distance ] ──▶ Double EMA ──┐ │
│ ├────▶ Ratio Division ──▶ Output │
│ [ Trading Range ] ──▶ Double EMA ──┘ │
│ │
│ BRESSERT'S DSS: │
│ [ Raw Price ] ──▶ Stoch Normalization ──▶ Smooth ──┐ │
│ ▼ │
│ [ Output ] ◀── Smooth ◀── Stoch Normalization over Smoothed Y │
│ │
└────────────────────────────────────────────────────────────────────────┘
```
### Key Capabilities (v3.20 Enterprise Edition)
- **Decoupled Dual-Stage Smoothing Laboratory:** Independently select periods and moving average types (SMA, EMA, SMMA, LWMA, TMA, DEMA, TEMA, VWMA) for Stage 1, Stage 2, and Signal Line.
- **Volume-Weighted DSS (VWMA Support):** Supports volume weighting across all smoothing stages, anchoring cycle inflection points directly to institutional trading volume.
- **Clean Candle Source Architecture:** Replaces confusing 1D price lists with direct `CANDLE_STANDARD` and `CANDLE_HEIKIN_ASHI` options, utilizing in-place synthetic price mapping.
- **Zero-Lag MTF Fast-Path:** Higher-timeframe curves project onto lower-timeframe execution charts as non-warping flat steps via `DataSync_Tools.mqh` with zero `iBarShift` overhead on live ticks.
- **Embedded Zero-Heap Engines:** Completely eliminates runtime pointer allocations (`new`/`delete`), running through 3 persistent `CMovingAverageCalculator` member processors in $O(1)$ incremental time.
---
## 2. Mathematical Foundations & The 5-Step Bressert Pipeline
```text
Raw Price (OHLC) ──▶ Step 1: First Stochastic (FastK1 on Price)
│
▼
Stage 1: Smoothing ──▶ Step 2: Smooth FastK1 ──▶ Y Series
│
▼
Stoch-of-Stoch ──▶ Step 3: Second Stochastic (FastK2 on Y Series)
│
▼
Stage 2: Smoothing ──▶ Step 4: Smooth FastK2 ──▶ DSS Bressert Line
│
▼
Signal Smoothing ──▶ Step 5: Smooth DSS ──▶ Signal Line
```
### 2.1. Step 1: Primary Stochastic Normalization ($\text{FastK}_1$)
Given lookback window $P = \text{InpStochPeriod}$:
$$\text{HH}_1(t) = \max_{j=0 \dots P-1} (\text{High}_{t-j})$$
$$\text{LL}_1(t) = \min_{j=0 \dots P-1} (\text{Low}_{t-j})$$
$$\text{Range}_1(t) = \text{HH}_1(t) - \text{LL}_1(t)$$
$$\text{FastK}_1(t) = \begin{cases} \frac{\text{Close}_t - \text{LL}_1(t)}{\text{Range}_1(t)} \cdot 100, & \text{if } \text{Range}_1(t) > 10^{-9} \\ \text{FastK}_1(t-1), & \text{otherwise} \end{cases}$$
---
### 2.2. Step 2: First-Stage Smoothing Cascade ($Y_t$)
$\text{FastK}_1$ is smoothed using `InpSmoothMAType1` across $S_1 = \text{InpSmoothPeriod1}$:
$$Y_t = \text{MovingAverage}(\text{FastK}_1, S_1, \text{InpSmoothMAType1})_t$$
---
### 2.3. Step 3: Secondary Stochastic Normalization on Smoothed Space ($\text{FastK}_2$)
The core innovation of Walter Bressert: finding the Highest and Lowest of the smoothed $Y$ curve over the same lookback window $P$:
$$\text{MaxY}_P(t) = \max_{j=0 \dots P-1} (Y_{t-j})$$
$$\text{MinY}_P(t) = \min_{j=0 \dots P-1} (Y_{t-j})$$
$$\text{RangeY}_P(t) = \text{MaxY}_P(t) - \text{MinY}_P(t)$$
$$\text{FastK}_2(t) = \begin{cases} \frac{Y_t - \text{MinY}_P(t)}{\text{RangeY}_P(t)} \cdot 100, & \text{if } \text{RangeY}_P(t) > 10^{-9} \\ \text{FastK}_2(t-1), & \text{otherwise} \end{cases}$$
---
### 2.4. Step 4: Second-Stage Smoothing Cascade ($\text{DSS}_t$)
$\text{FastK}_2$ is smoothed a second time using `InpSmoothMAType2` across $S_2 = \text{InpSmoothPeriod2}$ to produce the final DSS curve:
$$\text{DSS}_t = \text{Clamp}\Big( \text{MovingAverage}(\text{FastK}_2, S_2, \text{InpSmoothMAType2})_t, \; 0.0, \; 100.0 \Big)$$
---
### 2.5. Step 5: Signal Line Generation ($\text{Signal}_t$)
The trigger line is generated by smoothing $\text{DSS}_t$ over $P_{\text{signal}} = \text{InpSignalPeriod}$ using `InpSignalMAType`:
$$\text{Signal}_t = \text{MovingAverage}(\text{DSS}, P_{\text{signal}}, \text{InpSignalMAType})_t$$
---
### 2.6. Symmetrical 5-Zone Indicator Level Matrix
| Level Value | Level Name | Market Cycle State | Institutional Interpretation |
| :---: | :---: | :--- | :--- |
| **90.0** | **Extreme Overbought** | Parabolic buying climax; exhaustion imminent. | Tighten trailing stops; prepare for V-reversal short. |
| **80.0** | **Overbought Warning** | Strong bullish trend momentum active. | Bullish expansion zone; trail stops below DSS. |
| **50.0** | **Equilibrium Centerline** | Symmetrical zero-bias cycle inflection line. | Directional pivot: $>50$ Bullish bias, $<50$ Bearish bias. |
| **20.0** | **Oversold Warning** | Strong bearish trend momentum active. | Bearish expansion zone; trail stops above DSS. |
| **10.0** | **Extreme Oversold** | Capitulation liquidation floor; short squeeze risk. | High-conviction V-bottom bounce zone; initiate longs. |
---
## 3. MQL5 Architecture & Computational Benchmarking
```text
┌────────────────────────────────────────────────────────┐
│ DSS_Bressert_Calculator.mqh │
│ (3 Embedded MA Processors + In-Place Heikin Ashi) │
└──────────────────────────┬─────────────────────────────┘
│ Delivers DSS & Signal in O(1)
▼
┌────────────────────────────────────────────────────────┐
│ DSS_Bressert_Pro.mq5 │
│ (Unified Native & Zero-Lag MTF Fast-Path) │
├──────────────────────────┬─────────────────────────────┤
│ Buffer Layer (2) │ Centralized Framework │
│ • BufferDSS (Plot 1) │ • DataSync_Tools.mqh │
│ • BufferSignal (Plot 2)│ • Atomic CopyRates MTF │
│ │ • Binary Search Snapping │
└──────────────────────────┴─────────────────────────────┘
```
### Engineering Benchmark: Legacy DSS vs. Enterprise v3.20
| Metric | Conventional DSS Implementations | Enterprise Refactor (v3.20) | Net Optimization |
| :--- | :---: | :---: | :---: |
| **Smoothing Architecture** | Hardcoded EMA only | **Decoupled 8-Method Engines + VWMA** | **Total Modularity** |
| **MTF Live-Tick `iBarShift`** | Up to 500 calls per tick | **0 calls on live ticks (`ArrayBsearch`)** | **Complete Zero-Lag** |
| **MTF Data Copy Calls** | 5 separate calls per tick | **1 atomic `CopyRates` query** | **-80.0% API Overhead** |
| **Heap Memory Churn** | Dynamic arrays every tick | **Persistent Embedded Objects** | **Zero Allocation Pauses** |
| **Pointer Safety** | Slow `CheckPointer()` on ticks | **Fast `if(!g_calculator)` Guard** | **Optimized Branching** |
| **Multi-Window Scalability** | Severe UI lag on 14 charts | **Silky-smooth execution on >14 charts** | **Enterprise Certified** |
---
## 4. Parameters Reference
### Timeframe Settings
- `InpTimeframe` (*default: `PERIOD_CURRENT`*): Calculation timeframe. Set to `PERIOD_CURRENT` for native zero-lag execution, or choose a higher timeframe (e.g., `PERIOD_M5`, `PERIOD_H1`) to activate the synchronized MTF engine.
### Stochastic Core Settings
- `InpStochPeriod` (*default: `10`*): Stochastic lookback period applied across both Stage 1 and Stage 3 normalization ($P$).
- `InpCandleSource` (*default: `CANDLE_STANDARD`*): Price input series (`CANDLE_STANDARD` for regular OHLC or `CANDLE_HEIKIN_ASHI` for synthetic smoothed OHLC).
### Stage 1 Smoothing (FastK1 $\to Y$)
- `InpSmoothPeriod1` (*default: `3`*): Smoothing period for the first-stage smoothing ($S_1$).
- `InpSmoothMAType1` (*default: `EMA`*): Moving average algorithm applied to Stage 1 (Supports SMA, EMA, VWMA, DEMA, etc.).
### Stage 2 Smoothing (FastK2 $\to$ DSS Line)
- `InpSmoothPeriod2` (*default: `3`*): Smoothing period for the second-stage smoothing ($S_2$).
- `InpSmoothMAType2` (*default: `EMA`*): Moving average algorithm applied to Stage 2.
### Signal Line Settings
- `InpSignalPeriod` (*default: `3`*): Lookback period for smoothing the DSS line into the Signal line.
- `InpSignalMAType` (*default: `EMA`*): Moving average algorithm applied to the signal line.
### Visual Settings
- `InpColorDSS` (*default: `clrDodgerBlue`*): Color of the primary DSS Bressert curve (Width: 2, Solid).
- `InpColorSignal` (*default: `clrCoral`*): Color of the smoothed Signal line (Width: 1, Solid).
---
## 5. Quantitative Trading Playbooks
```text
┌────────────────────────────────────────────────────────────────────────┐
│ DSS BRESSERT QUANTITATIVE PLAYBOOKS │
├────────────────────────────────────────────────────────────────────────┤
│ 1. V-Shape Cycle Pivot Reversal:Fade extreme climaxes when DSS > 90 │
│ or < 10 and hooks sharply in reverse. │
│ 2. Trend Continuation Pullback: Buy pullbacks when DSS bounces off the │
│ 20 or 50 level in an established trend.│
│ 3. Volume-Weighted DSS Cross: Use VWMA smoothing to confirm cycle │
│ turns backed by institutional volume. │
└────────────────────────────────────────────────────────────────────────┘
```
### 5.1. V-Shape Cycle Pivot Reversal (The Bressert Edge)
- **Premise:** Because Bressert normalizes the smoothed curve a second time, DSS exhibits dramatic acceleration at cycle turning points, forming sharp V-reversals rather than sluggish rounding tops/bottoms.
- **Bullish Capitulation Pivot ($< 10$):**
1. Price undergoes a waterfall selloff; DSS flushes below **10.0 (`InpLevel1`)**.
2. DSS forms a sharp V-pivot and crosses **above the Signal line** while inside or immediately exiting the $<20$ zone.
3. **Enter Long:** Stop-loss placed below the swing low. Target: 50.0 centerline and opposing 80.0 overbought zone.
- **Bearish Exhaustion Pivot ($> 90$):**
1. Price surges into a buying climax; DSS expands above **90.0 (`InpLevel5`)**.
2. DSS forms a sharp inverted V-pivot and crosses **below the Signal line** $\rightarrow$ **Enter Short**.
### 5.2. Trend Continuation Pullback (The 50/20 Bounce)
- **Bullish Setup:**
- Price is in an established markup trend (trading above SuperSmoother / VWAP).
- DSS pulls back downward, dipping into the **50.0 equilibrium level** or momentarily testing the **20.0 oversold level**.
- DSS hooks upward and crosses strictly **above the Signal line** while holding above 20.0 $\rightarrow$ **Enter Long**.
### 5.3. Volume-Weighted DSS Inflection (VWMA Power Setup)
- Set `InpSmoothMAType1 = VWMA` or `InpSmoothMAType2 = VWMA`.
- The smoothing cascade now factors in tick or exchange volume:
- High-volume cycle pivots turn DSS with extreme sharpness.
- Low-volume false breakouts fail to turn the curve, keeping DSS locked in trend.
---
## 6. Indicator Buffer Map (For Developers & EA Integration)
### Buffer Allocation
| Buffer Index | Name | Type | Visual Plot | Description |
| :---: | :---: | :---: | :---: | :--- |
| **0** | `BufferDSS` | `INDICATOR_DATA` | Plot 1 (`DRAW_LINE`) | Main Walter Bressert Double Smoothed Stochastic line. |
| **1** | `BufferSignal` | `INDICATOR_DATA` | Plot 2 (`DRAW_LINE`) | Smoothed Signal line. |
*All buffers strictly maintain non-series chronological order (`ArraySetAsSeries = false`), ensuring direct compatibility with automated Expert Advisors via `iCustom()`.*
---
### MQL5 EA Integration Interface Template
```mql5
//+------------------------------------------------------------------+
//| EA_DSS_Bressert_Interface |
//| Copyright 2026, xxxxxxxx|
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, xxxxxxxx"
#property version "1.00"
#property strict
//--- Include Calculator Definitions
#include <MyIncludes\DSS_Bressert_Calculator.mqh>
//--- EA Inputs
input group "=== DSS Bressert Filter Parameters ==="
input ENUM_TIMEFRAMES InpDSSTimeframe = PERIOD_CURRENT; // Timeframe
input int InpStochPeriod = 10; // Lookback (P)
input ENUM_CANDLE_SOURCE InpCandleSource= CANDLE_STANDARD; // Candle Source
input int InpSmoothPeriod1 = 3; // Smooth 1 (S1)
input ENUM_MA_TYPE InpSmoothMAType1 = EMA; // Smooth 1 MA Type
input int InpSmoothPeriod2 = 3; // Smooth 2 (S2)
input ENUM_MA_TYPE InpSmoothMAType2 = EMA; // Smooth 2 MA Type
input int InpSignalPeriod = 3; // Signal Period
input ENUM_MA_TYPE InpSignalMAType = EMA; // Signal MA Type
//--- Global Indicator Handle
int g_dss_handle = INVALID_HANDLE;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
if(g_dss_handle != INVALID_HANDLE)
IndicatorRelease(g_dss_handle);
// Instantiate handle to DSS_Bressert_Pro via iCustom
g_dss_handle = iCustom(_Symbol,
InpDSSTimeframe,
"DSS_Bressert_Pro",
InpDSSTimeframe,
InpStochPeriod,
InpCandleSource,
InpSmoothPeriod1, InpSmoothMAType1,
InpSmoothPeriod2, InpSmoothMAType2,
InpSignalPeriod, InpSignalMAType);
if(g_dss_handle == INVALID_HANDLE)
{
PrintFormat("EA Error: Failed to create handle for DSS_Bressert_Pro. Error: %d", GetLastError());
return INIT_FAILED;
}
Print("EA Success: DSS_Bressert_Pro handle initialized successfully.");
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(g_dss_handle != INVALID_HANDLE)
{
IndicatorRelease(g_dss_handle);
g_dss_handle = INVALID_HANDLE;
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
// Query completed closed candle (Shift = 1) and previous candle (Shift = 2) for DSS and Signal
double dss_vals[2], signal_vals[2];
ArraySetAsSeries(dss_vals, true); // Index 0 = Shift 1, Index 1 = Shift 2
ArraySetAsSeries(signal_vals, true);
if(CopyBuffer(g_dss_handle, 0, 1, 2, dss_vals) < 2 || // Buffer 0 = DSS
CopyBuffer(g_dss_handle, 1, 1, 2, signal_vals) < 2) // Buffer 1 = Signal
{
return; // Data synchronizing
}
double dss_bar1 = dss_vals[0];
double sig_bar1 = signal_vals[0];
// Quantitative State Analysis
bool is_climax_high = (dss_bar1 >= 90.0);
bool is_climax_low = (dss_bar1 <= 10.0);
bool is_overbought = (dss_bar1 >= 80.0);
bool is_oversold = (dss_bar1 <= 20.0);
bool is_bullish_bias = (dss_bar1 > 50.0);
bool is_bearish_bias = (dss_bar1 < 50.0);
// Momentum Crossover Signals
bool signal_crossed_up = (dss_vals[1] <= signal_vals[1] && dss_vals[0] > signal_vals[0]);
bool signal_crossed_down = (dss_vals[1] >= signal_vals[1] && dss_vals[0] < signal_vals[0]);
// Telemetry Output
Comment(StringFormat("DSS Bressert Telemetry [Bar 1]:\n"
"DSS: %.2f | Signal: %.2f\n"
"Bias: %s | State: %s\n"
"Crossover Signals -> Buy: %s | Sell: %s",
dss_bar1, sig_bar1,
is_bullish_bias ? "BULLISH (> 50.0)" : (is_bearish_bias ? "BEARISH (< 50.0)" : "EQUILIBRIUM"),
is_climax_high ? "EXTREME CLIMAX (>= 90)" :
(is_climax_low ? "EXTREME CAPITULATION (<= 10)" :
(is_overbought ? "OVERBOUGHT (>= 80)" :
(is_oversold ? "OVERSOLD (<= 20)" : "NORMAL RANGE"))),
(signal_crossed_up && is_bullish_bias) ? "TRIGGERED (Bullish Pivot)" : "NO",
(signal_crossed_down && is_bearish_bias) ? "TRIGGERED (Bearish Pivot)" : "NO"));
}
//+------------------------------------------------------------------+
```