Double HULL Moving Average Strategy

Author: ChaoZhang, Date: 2023-09-15 16:39:48
Tags:

Strategy Overview:

The Double HULL Moving Average Strategy is a trading strategy based on the HULL Moving Average (HMA) indicator created by Alan HULL. The strategy utilizes two HMA lines, a longer-term line and a shorter-term line, to determine entry and exit points. The HMA is an improved moving average that reduces lag by applying weighted averaging to the price data. The crossover of the shorter-term and longer-term lines is used to generate buy and sell signals.

The calculation formula for the HMA is as follows:

HmaL = wma(2 * wma(close, round(PDL/2)) - wma(close, PDL), round(sqrt(PDL)))
HmaS = wma(2 * wma(close, round(PDS/2)) - wma(close, PDS), round(sqrt(PDS)))

Here, PDL represents the longer-term period, and PDS represents the shorter-term period. The strategy compares the values of the shorter-term and longer-term lines to determine the conditions for buying and selling.

Advantages:

  1. Reduced lag: The HMA has less lag compared to traditional moving averages, enabling it to respond faster to changes in price trends and provide more accurate signals for buying and selling.
  2. Simplicity: The strategy uses two moving average lines for crossover analysis, making it relatively simple to understand and implement.
  3. High customization: The strategy’s period parameters can be adjusted based on specific markets and trading instruments, making it more adaptable to different market conditions.

Risks:

  1. Market volatility: During periods of market volatility, the moving average lines may cross frequently, resulting in frequent signals that can generate false signals and lead to excessive trading and losses.
  2. Slippage and latency: The execution of the strategy is subject to slippage and latency, especially in high-frequency trading, which can cause executed prices to deviate from expected prices and affect trading outcomes.
  3. Dependency on a single indicator: The strategy relies solely on the HMA indicator without incorporating other technical indicators or market intelligence, which may limit its ability to capture the full range of market changes and trends.

Conclusion:

The Double HULL Moving Average Strategy is a trading strategy based on the HULL Moving Average indicator. It utilizes the crossover of shorter-term and longer-term HMA lines to determine entry and exit points. The strategy offers advantages such as reduced lag, simplicity, and high customization. However, it also carries risks related to market volatility, slippage and latency, and reliance on a single indicator. In practical applications, the strategy can be adjusted and optimized based on specific circumstances, incorporating other technical indicators and risk management methods to enhance trading success and profitability.


/*backtest
start: 2023-09-07 00:00:00
end: 2023-09-14 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
// Credit Indicator from KIVANC
// author and idea: KIVANC @fr3762 on twitter
// creator: Alan HULL
// 
strategy("Double HULL Moving Average Strategy", overlay=true)
PDL=input(title="LongerPeriod", defval=21, minval=1,maxval=500)
PDS=input(title="ShorterPeriod",  defval=8, minval=1,maxval=500)

// === INPUT BACKTEST RANGE ===
FromYear  = input(defval = 2019, title = "From Year", minval = 2009)
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
ToYear    = input(defval = 9999, title = "To Year", minval = 2009)
ToMonth   = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
ToDay     = input(defval = 31, title = "To Day", minval = 1, maxval = 31)

// === FUNCTION EXAMPLE ===
start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => true // create function "within window of time"

HmaL=wma(2*wma(close,round(PDL/2))-wma(close,PDL),round(sqrt(PDL)))
HmaS=wma(2*wma(close,round(PDS/2))-wma(close,PDS),round(sqrt(PDS)))
plot(HmaL,color=red, linewidth=2)
plot(HmaS,color=blue, linewidth=2)

Buy = HmaS > HmaL
Sell = HmaS < HmaL

strategy.entry("Buy",true,when=window() and Buy)
strategy.close_all(when=window() and Sell)

More