Hodrick-Prescott filter [Jamallo]

1 171
(2025)

Intro

The Hodrick-Prescott (HP) filter is a tool originally developed by economists to remove short-term noise from data and reveal the underlying long-term trend — think of it like a moving average, but mathematically smarter.

Instead of just averaging recent prices, it solves for the smoothest possible trendline that still follows the data. Applied to price, it produces a cleaner baseline than most traditional moving averages.
---
However it comes with 3 problems in practical day trading.

Problem #1 Standard HP Repaints History (core issue)
The standard HP filter is non-causal — the value at any point in time depends on future values CEPR, meaning past signals can change retroactively.

How I solved it:
Switching to a one-sided implementation fixes this — it only looks at past data, so history never changes once a bar closes.

Problem #2 One-Sided HP Hooks at Turns
Going one-sided introduces an endpoint artifact — near turning points the trend line briefly curves in the wrong direction before reversing, producing a false signal.

How I solved it:
Feeding the HP output into a range filter solves this. The line only moves when HP breaks outside a volatility band, so the false hook gets absorbed into a flat zone and never fires a signal.

Problem #3 Fixed Band Would Be Too Rigid
A fixed band would whipsaw in volatile markets and lag in calm ones.

How I solved it:
Instead the band is sized dynamically using a percentile of True Range, scaling automatically with current market conditions.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。