Variable Index Dynamic Average
VIDYA is an exponential moving average with an adaptive twist: the usual fixed smoothing constant 2/(N+1) is multiplied every bar by a volatility index between 0 and 1, so the average reacts closer to price during an active, directional market and flattens out during a quiet one - all without changing the underlying window length the way a variable-period MA would. Chande's original 1992 design derives that volatility index from the Chande Momentum Oscillator: the absolute value of (sum of up moves minus sum of down moves) divided by (sum of up moves plus sum of down moves) over the window, which is naturally already bounded to 0..1 and rewards a market moving persistently in one direction. A second, commonly used alternative compares a short-term standard deviation to a longer-term one, clipped to 0..1 - a market that has recently gotten calmer relative to its own longer history slows the average down, and vice versa. Both are legitimate, published ways to drive the same recursion, and traders reasonably prefer one or the other depending on the instrument, so this indicator exposes both behind one input rather than picking a single "correct" one. Notes and limitations - Both volatility indices are bounded to [0,1] by construction or explicit clipping, but a genuinely dead market (zero net movement, in CMO mode) can drive the index all the way to 0, effectively freezing the average until movement resumes - expected behaviour, not a bug. - Seeded at the oldest available bar with that bar's raw close; the seeding transient washes out over the first several dozen bars, same as any recursive average. - VI_STDEV_RATIO needs InpPeriod * InpStdevLongMultiple bars of history before it can compute at all, more than VI_CMO_RATIO needs for the same InpPeriod - the indicator waits for that much history rather than producing a partially-formed early reading.
Indicator · MT4 · v1.0 · Free
About Variable Index Dynamic Average
Variable Index Dynamic Average is an indicator for MetaTrader 4. It has 3 settings, such as Period, Volatility mode and Stdev long multiple. MQL source code included.
Files in the download: VidyaMa.mq4, VidyaMa.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 9 | N - sets the EMA-equivalent base smoothing constant 2/(N+1) |
| Volatility mode | VI_CMO_RATIO | Volatility index source |
| Stdev long multiple | 4 | Long stdev window = InpPeriod * this multiple (VI_STDEV_RATIO only) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Moving Average · MT4 Indicator · MQL4 Source Code