Type/to search

Vertical Horizontal Filter Backtest Strategy

Common strategy
Created: 2024-01-08 10:20:25
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview: This strategy judges whether prices are in a trend state by calculating the ratio between the difference between the highest and lowest prices over a certain period and the amplitude of the closing price, and uses this as a trading signal indicator.

Strategy Principle: The core indicator of this strategy is Vertical Horizontal Filter (VHF). It is calculated by the following formula:

VHF = (Highest(Length) - Lowest(Length)) / SUM(ABS(Close-Close[1]), Length)

Where Highest(Length) and Lowest(Length) are respectively the highest and lowest prices within the Length cycle. The numerator reflects the amplitude range of prices, and the denominator reflects the actual fluctuation of prices. Their ratio can judge the trend of price moves. When VHF is higher than a given signal threshold, it is considered that prices are in a trend state. When lower than the given signal threshold, it is considered that prices are in a shock state. Trading signals are generated accordingly.

This strategy is simple and intuitive. By comparing the price fluctuation range with the actual fluctuation to judge the trend, it avoids the problem of relying solely on SMA, EMA and other indicators while ignoring the characteristics of the price itself. But this strategy is sensitive to parameter optimization, Length and Signal parameters need to be adjusted to adapt to different cycles and market conditions.

Advantage Analysis:

  1. Intuitive trend judgment indicator, simple and effective.
  2. Consider the characteristics of the price itself, does not rely on any curve fitting.
  3. Configurable parameters adjust the sensitivity of judgment.
  4. Can be easily integrated into various trading strategies.

Risk Analysis:

  1. Sensitive to parameters, improper settings can cause too many false trades.
  2. Unable to distinguish pseudo trends when prices are at inflection points.
  3. Not sensitive to short-term price shocks under large cycle settings.
  4. Need to use stop loss to control single loss.

Optimization Directions:

  1. Optimize Length parameter to balance the sensitivity of trend judgment.
  2. Combine other indicators to filter VHF signals. For example, MACD can determine inflection points.
  3. Try machine learning methods to fit the VHF curve.
  4. Set up parallel strategies with different cycle settings to generate multi-level strategy signals.

Summary: This strategy intuitively determines the trend based on the characteristics of the price itself, simple and valid, worth further exploration, optimization and verification. It can become a basic trend judgment tool and widely used in quantitative trading strategies.

Source
Pine
/*backtest
start: 2023-01-01 00:00:00
end: 2024-01-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 27/04/2018
// Vertical Horizontal Filter was initiated by Adam White. It was first published 
Strategy parameters
Strategy parameters
Length
Signal
Trade reverse
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)