0bps

Strategy vault / Trend following

Double Hull Moving Average Crossover Trading Strategy

This strategy mainly uses the crossover of two Hull Moving Averages of different timeframes to determine market trends and make long and short trades. The strategy uses two Hull Moving Averages, one is 60 periods and…

Author
ChaoZhang
Complexity
Starter · 42 lines
Parameters
4
Backtest bar
2h · intraday
Tested on
BTC/USDT · futures

This strategy mainly uses the crossover of two Hull Moving Averages of different timeframes to determine market trends and make long and short trades.

Strategy Logic

The strategy uses two Hull Moving Averages, one is 60 periods and the other is 175 periods. Where:

  1. hullma is the 60-period Hull Moving Average, calculated by the wma function.

  2. ahullma is the 175-period Hull Moving Average, calculated by the wma function.

  3. When hullma crosses ahullma upward, a golden cross occurs, giving a long signal.

  4. When hullma crosses ahullma downward, a death cross occurs, giving a short signal.

  5. longCondition and shortCondition determine the long and short entry conditions respectively.

  6. The strategy.entry function is used to execute long and short trades.

The strategy utilizes the crossover principle to capture trend changes using the crossovers between short-term and long-term moving averages, for profit.

Advantage Analysis

  1. Hull Moving Average responds faster to price changes.

  2. Crossover principle is simple and easy to implement.

  3. The 60- and 175-period combination captures medium-term trends.

  4. Customizable period parameters for different markets.

  5. Applicable for intraday and position trading.

Risk Analysis

  1. Crossovers have some lag in signals.

  2. More false signals from short-term MA.

  3. Frequent crossovers may cause losses in range-bound markets.

  4. Wrong period settings cannot capture trend changes.

  5. Need parameter optimization for different symbols.

Risks can be mitigated by adding filters, optimizing parameters, allowing wider stops.

Optimization Directions

  1. Test different MA combinations to find optimal periods.

  2. Add trend indicators for signal filtering.

  3. Optimize stop loss strategy to reduce frequent stops.

  4. Adjust periods for different symbols.

  5. Add machine learning to dynamically optimize parameters.

Summary

This strategy utilizes golden cross and death cross principles to determine trends using double Hull Moving Average crossovers. It is a typical short-term dual moving average system. The pros are simple logic and easy implementation, catching fast short-term trends. The cons are high false signals and lagging issues. Improvements can be made via parameter optimization, signal filtering etc. It is a worthwhile short-term trading strategy to study. The strategy can be flexibly applied for intraday and position trading across different markets. Overall, it is suitable for short-term trading and can generate good returns if used properly.

Parameters

NameDefaultWhat it controls
v_input_160HULL MA 1 LENGTH
v_input_2_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_3175HULL MA 2 LENGTH
v_input_4_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4

Source Pine Script

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

//@version=4
strategy(title = "Hull MA", shorttitle="Junior2", overlay = true)

//HULL MA 1

length = input(60, minval=1,title="HULL MA 1 LENGTH")
src = input(close, title="Source")
hullma = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))

plot(hullma, color=color.green)

//HULLMA 2

alength = input(175, minval=1,title="HULL MA 2 LENGTH")
asrc = input(close, title="Source")
ahullma = wma(2*wma(asrc, alength/2)-wma(asrc, alength), round(sqrt(alength)))

plot(ahullma, color=color.green)

c1up= crossover(hullma,ahullma)
c1down= crossunder(hullma,ahullma)

longCondition = c1up
if longCondition

    strategy.entry("L", strategy.long)


shortCondition = c1down 
if shortCondition

    strategy.entry("S", strategy.short)

plot(close)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-11. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Double-Hull-Moving-Average-Crossover-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open