Author: Andrey N. Bolkonsky
The Ergodic Mean Deviation Index (MDI) Oscillator, developed by William Blau, is a powerful tool for traders, drawing insights from the Mean Deviation Index. For a deeper dive into this concept, check out Momentum, Direction, and Divergence: Applying the Latest Momentum Indicators for Technical Analysis.
How to Get Started
To use the Ergodic MDI Oscillator, you'll need to set up a couple of files in your MetaTrader 5 environment:
- Place WilliamBlau.mqh in terminal_data_folder\MQL5\Include\
- Put Blau_Ergodic_MDI.mq5 in terminal_data_folder\MQL5\Indicators\

Ergodic MDI-Indicator by William Blau
Understanding the Calculation
The Ergodic Mean Deviation Oscillator is calculated using the following formulas:
Ergodic_MDI(price,r,s,u) = MDI(price,r,s,u)
SignalLine(price,r,s,u,ul) = EMA( Ergodic_MDI(price,r,s,u) ,ul)
Here's a breakdown of the components:
- Ergodic_MDI() - The primary function calculating the Ergodic MDI;
- SignalLine() - This is the Signal Line, which represents the exponentially smoothed moving average of a specified period, applied to the Ergodic MDI;
- ul - The period for the EMA of the Signal Line.
Input Parameters
- Graphic Plot #0 - Ergodic (Mean Deviation Indicator):
- r - Period of the first EMA applied to price (default is r=20);
- s - Period of the second EMA applied to mean deviation (default is s=5);
- u - Period of the third EMA applied to the result of the second smoothing (default is u=3);
- Graphic Plot #1 - Signal Line:
- ul - EMA period of the Signal Line applied to the Ergodic MDI (default is ul=3);
- AppliedPrice - Type of price used (default is AppliedPrice=PRICE_CLOSE).
Important Notes
- Ensure that r > 1;
- s > 0 and u > 0. If r, s, or u = 1, no smoothing is applied;
- ul > 0. If ul = 1, the Signal Line and Mean Deviation Index will be identical;
- Minimum rates must equal (r + s + u + ul - 4 + 1).

Comments 0