VAMA_MACD Indicator For MT5
The VAMA_MACD Indicator For MT5 draws colored histogram bars at the bottom of the price chart based on the complex calculations of different kinds of the moving average. When the bars are formed at the positive side of the reference line, it means the market is in the uptrend. On the contrary, when the bars are formed on the negative side of the reference line, it means the sellers are pushing the price down. To assess the volatility of the market, you need to look at the signal curve. When the volatility is high the signal curve which is colored in red will deviate away from the dashed blue line. When the market ceases its volatility, both of the lines will closely trade in the indicator window.
Installing the VAMA_MACD 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 VAMA_MACD.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 VAMA_MACD Indicator For MT5
The VAMA_MACD Indicator For MT5 has 4 parameters to configure.
input uint InpPeriodFastMA = 12; // Fast MA period
input uint InpPeriodSlowMA = 26; // Slow MA period
input uint InpPeriodSignal = 9; // Signal line period
input ENUM_APPLIED_PRICE InpAppliedPrice = PRICE_CLOSE; // Applied price
Buffers of the VAMA_MACD Indicator For MT5
The VAMA_MACD Indicator For MT5 provides 5 buffers.
SetIndexBuffer(0,BufferMACD,INDICATOR_DATA);
SetIndexBuffer(1,BufferSignal,INDICATOR_DATA);
SetIndexBuffer(2,BufferHistogram,INDICATOR_DATA);
SetIndexBuffer(3,BufferColors,INDICATOR_COLOR_INDEX);
SetIndexBuffer(4,BufferMA,INDICATOR_CALCULATIONS);
Main Parts Of The Code
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- #AB0= gt 2:0 lt 0AA82 gt 2 1CD5@ gt 2 :0: B09 lt A5@89
ArraySetAsSeries(tick_volume,true);
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
if(rates_total lt period_max) return 0;
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
int limit=rates_total-prev_calculated;
if(limit gt 1)
{
limit=rates_total-period_max-2;
ArrayInitialize(BufferMACD,0);
ArrayInitialize(BufferSignal,0);
ArrayInitialize(BufferHistogram,0);
ArrayInitialize(BufferMA,0);
}
//--- gt 43 gt B gt 2:0 40==KE
int count=(limit gt 1 ? rates_total : 1),copied=0;
copied=CopyBuffer(handle_ma,0,0,count,BufferMA);
if(copied!=count) return 0;
//--- 0AGQB MACD
for(int i=limit; i gt =0 && !IsStopped(); i--)
{
double S_PV_Short=SumPrVolume(i,period_fma,tick_volume);
double S_PV_Long=SumPrVolume(i, period_sma,tick_volume);
double S_V_Short=SumVolume(i, period_fma,tick_volume);
double S_V_Long=SumVolume(i,period_sma,tick_volume);
if(S_V_Long!=0. && S_V_Short!=0.)
{
double MAS=S_PV_Short/S_V_Short;
double MAL=S_PV_Long/S_V_Long;
BufferMACD[i]=MAS-MAL;
}
}
//--- 0AGQB A83=0;L= gt 9 ;8=88 8 38AB gt 3@0 lt lt K
for(int i=limit; i gt =0 && !IsStopped(); i--)
{
double S_MACD=SumMACDVolume(i,period_sig,tick_volume);
double S_V=SumVolume(i,period_sig,tick_volume);
if(S_V!=0)
{
BufferSignal[i]=S_MACD/S_V;
BufferHistogram[i]=BufferMACD[i]-BufferSignal[i];
BufferColors[i]=
(
BufferHistogram[i] gt 0 ?
(BufferHistogram[i] gt BufferHistogram[i+1] ? 0 : 1) :
BufferHistogram[i] lt 0 ?
(BufferHistogram[i] lt BufferHistogram[i+1] ? 2 : 3) : 4
);
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| !C lt lt 0 F5= 8 gt 1JQ lt gt 2 |
//+------------------------------------------------------------------+
double SumPrVolume(const int index,const int period,const long &volume[])
{
double sum=0;
for(int i=index; i lt =index+period-1; i++)
sum+=BufferMA[i]*volume[i];
return sum;
}
//+------------------------------------------------------------------+
//| !C lt lt 0 7=0G5=89 MACD 8 gt 1JQ lt gt 2 |
//+------------------------------------------------------------------+
double SumMACDVolume(const int index,const int period,const long &volume[])
{
double sum=0;
for(int i=index; i lt =index+period-1; i++)
sum+=BufferMACD[i]*volume[i];
return sum;
}
//+------------------------------------------------------------------+
//| !C lt lt 0 gt 1JQ lt gt 2 |
//+------------------------------------------------------------------+
double SumVolume(const int index,const int period,const long &volume[])
{
double sum=0;
for(int i=index; i lt =index+period-1; i++)
sum+=(double)volume[i];
return sum;
}
//+------------------------------------------------------------------+