The Vertical Horizontal Filter, introduced by Adam White, is an indicator used to identify trending and ranging markets. In fact, similarly to the popular ADX indicator, the VHF estimates the raise / fall price acceleration, and thus attempts to predict whether we are going to deal with a trending or ranging market.
When the VHF rises, it indicates the beginning of an up or down trend, and when it falls, this is the signal for a ranging market. The higher the VHF is, the sharper the trend is, and the lower the VHF is, the more stable the range is. Some traders consider that when the VHF value reaches high levels, there is a high chance that the price reverses and moves in the opposite direction.
VHF formula calculation consists in dividing the range between the highest and lowest close price values over a time frame (of 28 day accordingly to White's original choice, although he now prefers an 18-day period averaged over 6 days) by the sum of the absolute values of the range between today and yesterday's close over the same period.
The VHF function I have created is named 'vh_filter' and it takes as argument the period over which the calculation is done.