Hodrick-Prescott Channel - MetaTrader 4 Script | Forex Indicators Download - MT4/MT5 Resources

Real author: winner
Channel brief description
This channel is an enhanced version of the MQL5 channel revised for MQL4.
First, calculate the filtered closing value. Then, filter them with a larger period. The result is two arrays: HP and HPSlow. The next step is to calculate the standard deviation of HP versus HPSlow and plot the channel.
The indicator displays the average spread value as a percentage in the lower right corner of the chart and the ratio of the channel width to the HPSlow value on the zero bar. Double-click the text label and drag it to the desired location. Press the DEL key to delete. The text reappears when switching time ranges.
How to correctly interpret the value of this channel?
This channel is based on the Hodrick-Prescott filter, a delay-free digital filter. These types of filters look nice compared to moving averages, but they redraw on every new bar.
Why does this happen? In fact, it is mathematically impossible to implement an "honest" filter without delay. The delay of any filter is equal to or greater than the number of bars set for averaging. This can be easily seen by changing the periods in the Moving Average indicator. The larger the period, the better the smoothing effect, but the greater the delay.
There is only one way to eliminate lag. The pure form of the algorithm is as follows: the input strips need to be filtered first from left to right, and then the resulting sequence is filtered again, this time from right to left. Also, the initial direction doesn't matter, just do the second filtering in the opposite direction.
In fact, various non-delay filters offer varying degrees of compromise between delay and smoothness. But it must be clearly understood that perfection is impossible to achieve because it is impossible to predict the future.
This filter must be used to determine the immediate direction of the price movement (at the level of several new bars). If both this channel and the standard deviation channel are attached to the chart, it is obvious that their directions are close to each other near the first (rightmost) bar. But if the standard deviation channel is drawn by three straight lines, then the channel shows the direction of price historically with a certain accuracy. And the deeper the history goes, the less accurate it becomes.
During the adaptation of the indicator to MQL4, I specifically added code for drawing the "tail" of the channel. Run it on the М1 timeframe, wait half an hour without changing the timeframe and you will see the channel wagging its "tail". When you switch time ranges, the "tail" disappears.
This indicator is recommended for scalping, it is not suitable for long-term strategies or to replace an "honest" moving average.
Indicator input parameters:

Attachment download
📎 vhpchannel_03.mq4 (15.63 KB)
Source: MQL5 #14737
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •