The DMI Stochastic, developed by Barbara Star, is an innovative oscillator that combines two powerful concepts: J. Welles Wilder's Directional Movement Index (DMI) and the Stochastic Oscillator.
Instead of analyzing the price, this indicator measures the **momentum of the underlying directional pressure** in the market. It does this by first creating an oscillator from the difference between the Positive (+DI) and Negative (-DI) Directional Indicators, and then feeding this new value series into a standard Stochastic calculation.
The result is an oscillator that identifies overbought and oversold conditions in bullish or bearish momentum itself, providing unique insights into potential trend exhaustion and reversals.
Our `DMIStochastic_Pro` implementation is a professional version that includes:
* Calculation based on either **standard** or **Heikin Ashi** candles.
* A user-selectable formula for the internal DMI Oscillator for more intuitive use.
## 2. Mathematical Foundations and Calculation Logic
The calculation is a three-stage process: first building the DMI components, then creating the DMI Oscillator, and finally applying the Stochastic formula.
### Required Components
* **DMI Period (N):** The lookback period for the DMI calculation (e.g., 10).
* **Stochastic Periods:** Fast %K Period, Slowing Period, and %D Period.
### Calculation Steps (Algorithm)
1.**Calculate Directional Indicators (+DI, -DI):** This initial step is identical to the standard ADX calculation.
* First, the raw Directional Movement (+DM, -DM) and True Range (TR) are calculated for each bar.
* These three series are then smoothed using Wilder's method (SMMA/RMA) over the DMI Period `N`.
2.**Create the DMI Oscillator:** This is the core of the indicator. An oscillator is created from the difference between the two directional indicators. Our implementation allows for two formulas:
All mathematical logic is encapsulated in a dedicated include file. This engine manages all intermediate calculations (DM, TR, DI, DMI Oscillator, Fast %K) internally.
* **Engine Integration:** The calculator internally uses two instances of our universal `MovingAverage_Engine.mqh` to handle the smoothing of the Slow %K and the %D Signal Line. This allows for advanced smoothing types (like DEMA or TEMA) beyond the standard SMA.
* The Heikin Ashi version (`CDMIStochasticCalculator_HA`) is achieved simply by instructing the main calculator to instantiate the Heikin Ashi version of the data preparation module.
The DMI Stochastic should be interpreted as a **momentum-of-momentum** oscillator. It shows when the bullish or bearish *pressure* is overextended. (Assuming default `PDI - NDI` formula).
* **Overbought/Oversold Momentum:**
* **Values > 80 (Overbought):** Indicates that bullish pressure has been extremely strong and dominant. This may signal that the bullish move is exhausted and a bearish reversal or consolidation is imminent.
* **Values < 20 (Oversold):** Indicates that bearish pressure has been extremely strong. This may signal that the bearish move is exhausted and a bullish reversal or consolidation is likely.
* **Crossovers:**
* When the **%K line (blue) crosses above the %D line (red)**, it signals a bullish shift in directional momentum.
* When the **%K line (blue) crosses below the %D line (red)**, it signals a bearish shift in directional momentum.