Vertical Horizontal Filter Indicator For MT5
The Vertical Horizontal Filter Indicator For MT5 is a very powerful tool that helps you to analyze the trading range of the price movement. Those who are used to the concept of ATR or average true range can take great advantage from this indicator. When the price of a certain asset is trading higher, the signal curve colored in blue will start trading higher. On the contrary, it will head north when the market is in the downtrend. Based on the movement of the signal curve you can get a clear idea about the direction of the trend. Pay special attention to the rate of change in the blue color signal curve. The strong spike in the north suggests the buyers are becoming more aggressive and the volatility is really high. On the contrary, the sudden drop in the blue color signal curve suggests the sellers are gaining strength. However, if the signal curve starts to trade in a slow pattern consider the market volatility as low.
Installing the Vertical Horizontal Filter 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 Vertical Horizontal Filter VHF.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 Vertical Horizontal Filter Indicator For MT5
The Vertical Horizontal Filter Indicator For MT5 has 2 parameters to configure.
input int inpVhfPeriod = 28; // VHF period
input ENUM_APPLIED_PRICE inpPrice = PRICE_CLOSE; // Price
Buffers of the Vertical Horizontal Filter Indicator For MT5
The Vertical Horizontal Filter Indicator For MT5 provides 3 buffers.
SetIndexBuffer(0,val,INDICATOR_DATA);
SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);
SetIndexBuffer(2,prices,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[])
{
if(Bars(_Symbol,_Period) lt rates_total) return(prev_calculated);
int i=(int)MathMax(prev_calculated-1,1); for(; i lt rates_total && !_StopFlag; i++)
{
prices[i]=getPrice(inpPrice,open,close,high,low,i,rates_total);
int start=MathMax(i-inpVhfPeriod+1,0);
double noise = 0; for(int k=0; k lt inpVhfPeriod && (i-k-1) gt =0; k++) noise += MathAbs(prices[i-k]-prices[i-k-1]);
double HCP = prices[ArrayMaximum(prices,start,inpVhfPeriod)];
double LCP = prices[ArrayMinimum(prices,start,inpVhfPeriod)];
val[i]=(noise!=0) ?(HCP-LCP)/noise : 0;
valc[i]=(i gt 0) ?(val[i] gt val[i-1]) ? 1 :(val[i] lt val[i-1]) ? 2 : valc[i-1]: 0;
}
return (i);
}
//+------------------------------------------------------------------+
//| Custom functions |
//+------------------------------------------------------------------+
double getPrice(ENUM_APPLIED_PRICE tprice,const double &open[],const double &close[],const double &high[],const double &low[],int i,int _bars)
{
switch(tprice)
{
case PRICE_CLOSE: return(close[i]);
case PRICE_OPEN: return(open[i]);
case PRICE_HIGH: return(high[i]);
case PRICE_LOW: return(low[i]);
case PRICE_MEDIAN: return((high[i]+low[i])/2.0);
case PRICE_TYPICAL: return((high[i]+low[i]+close[i])/3.0);
case PRICE_WEIGHTED: return((high[i]+low[i]+close[i]+close[i])/4.0);
}
return(0);
}
//+------------------------------------------------------------------+