Variable Index Dynamic Average VIDYA Indicator For MT5
The Variable Index Dynamic Average VIDYA Indicator For MT5 was developed by Tushan Chande and is an improved version of the Exponentional Moving Avearge indicator. The Vidya indicator has a dynamic period calculation. This means that instead of having a fixed period the indicator uses different periods according to the actual volatility in the market. This can make it more robust in the ever changing conditions of the financial markets.
Installing the Variable Index Dynamic Average VIDYA Indicator For MT5
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file vidya.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.
Parameters of the Variable Index Dynamic Average VIDYA Indicator For MT5
The Variable Index Dynamic Average VIDYA Indicator For MT5 has 3 parameters to configure.
input int InpPeriodCMO=9; // Period CMO
input int InpPeriodEMA=12; // Period EMA
input int InpShift=0; // Indicator s shift
Buffers of the Variable Index Dynamic Average VIDYA Indicator For MT5
The Variable Index Dynamic Average VIDYA Indicator For MT5 provides 1 buffers.
SetIndexBuffer(0,VIDYA_Buffer,INDICATOR_DATA);
Main Parts Of The Code
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{
//--- check for data
if(rates_total lt InpPeriodEMA+InpPeriodCMO-1)
return(0);
//---
int limit;
if(prev_calculated lt InpPeriodEMA+InpPeriodCMO-1)
{
limit=InpPeriodEMA+InpPeriodCMO-1;
for(int i=0;i lt limit;i++)
VIDYA_Buffer[i]=price[i];
}
else limit=prev_calculated-1;
//--- main cycle
for(int i=limit;i lt rates_total && !IsStopped();i++)
{
//--- calculate CMO and get absolute value
double mulCMO=fabs(CalculateCMO(i,InpPeriodCMO,price));
//--- calculate VIDYA
VIDYA_Buffer[i]=price[i]*ExtF*mulCMO+VIDYA_Buffer[i-1]*(1-ExtF*mulCMO);
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
//| Chande Momentum Oscillator |
//+------------------------------------------------------------------+
double CalculateCMO(int Position,const int PeriodCMO,const double &price[])
{
double resCMO=0.0;
double UpSum=0.0,DownSum=0.0;
if(Position gt =PeriodCMO && ArrayRange(price,0) gt Position)
{
for(int i=0;i lt PeriodCMO;i++)
{
double diff=price[Position-i]-price[Position-i-1];
if(diff gt 0.0)
UpSum+=diff;
else
DownSum+=(-diff);
}
if(UpSum+DownSum!=0.0)
resCMO=(UpSum-DownSum)/(UpSum+DownSum);
}
return(resCMO);
}
//+------------------------------------------------------------------+