The Variable Index Dynamic Average (VIDYA), developed by Tushar Chande, is a sophisticated adaptive moving average that automatically adjusts its speed based on market momentum. It uses the Chande Momentum Oscillator (CMO) to dynamically alter its smoothing factor. When momentum is high, VIDYA becomes more sensitive and follows prices closely. When momentum wanes in a consolidating market, it slows down and smooths out price action.
Our professional implementation is an **indicator family** consisting of two versions, both powered by a single, universal calculation engine:
* **`VIDYA_Pro`:** The classic, single-color implementation that acts as a pure adaptive trend line.
* **`VIDYA_Color_Pro`:** An enhanced version that changes color based on the direction of the underlying momentum (CMO positive or negative), providing an additional layer of visual information.
Both indicators support calculations based on either **standard** or **Heikin Ashi** price data.
* Then, calculate the VIDYA for each bar. Note that the formula uses the **absolute value** of the CMO (normalized to a 0-1 range) to adjust the speed, not the direction.
A single, powerful engine file contains all the core calculation logic. This eliminates code duplication and ensures that both `VIDYA_Pro` and `VIDYA_Color_Pro` produce identical average values.
* **Composition with CMO Engine:** The VIDYA calculator does not re-implement the CMO logic. Instead, it internally instantiates our lightweight `CMO_Engine.mqh`. This ensures that the momentum measurement is mathematically identical to the standalone CMO indicator, while maintaining high performance.
The engine uses a `CVIDYACalculator` base class and a `CVIDYACalculator_HA` derived class. The child class only overrides the `PreparePriceSeries` method to supply Heikin Ashi data.