Quant Trading Strategy Based on HullMA Percentage Bands
This strategy implements quantitative trading through calculating Hull moving average and its percentage bands to make entry and stop-loss decisions. Its advantages include adjustable parameters, simple…

Overview
This strategy implements quantitative trading through calculating Hull moving average and its percentage bands to make entry and stop-loss decisions. Its advantages include adjustable parameters, simple implementation, and strict stop loss. But risks like chasing peaks and killing dips, frequent trading also exist. Further optimizations on stop loss strategy and adding short-term operations could lead to better performance.
Strategy Principle
Calculate Hull moving average hullma with length length.
Plot percentage bands xL1, xL3, xL2, xL4 based on hullma.
Long when close crosses below xL2 or xL4, close long when close crosses above xL1, xL2 or xL3.
Advantage Analysis
The advantages include:
HullMA is sensitive to price changes and tracks trends well.
Percentage bands are highly adjustable for different products.
Dual bands strategy filters out wrong signals effectively.
Stop loss strategy controls risks effectively.
Risk Analysis
Some risks:
Chasing peaks and killing dips.
Slippage from frequent trading.
Improper parameter tuning leads to overtrading.
Stop loss position needs iterative optimization.
Optimization Directions
Some optimization directions:
Optimize hullMA length parameter for different products.
Optimize percentage bands to reduce wrong trades.
Add short-term operations to get more profits.
Optimize stop loss strategy to ensure effectiveness.
Test robustness across different products.
Conclusion
This strategy builds a relatively simple breakout trading system using HullMA and percentage bands. With clear pros and cons, and further optimizations on parameters and functionalities, it can become a very practical quant strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 9 | length |
| v_input_2_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_3 | 3 | Uband1 |
| v_input_4 | 3 | Lband1 |
| v_input_5 | 6 | Uband2 |
| v_input_6 | 6 | Lband2 |
Source Pine Script
/*backtest
start: 2023-03-01 00:00:00
end: 2024-02-29 00:00:00
period: 5d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("hullma percentage lines", overlay=true)
length = input(9, minval=1)
src = input(close, title="Source")
hullma = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length)))
plot(hullma)
Uband1 = input(3, minval=1, step = .5)
Lband1 = input(3, minval=1, step = .5)
Uband2 = input(6, minval=1, step = .5)
Lband2 = input(6, minval=1, step = .5)
v1 = Uband1+100
v2 = 100 - Lband1
v3 = Uband2+100
v4 = 100 - Lband2
xL1 = (hullma / 100) * v1
xL2 = (hullma / 100) * v2
xL3 = (hullma / 100) * v3
xL4 = (hullma / 100) * v4
plot(xL1, color=yellow, title="H1")
plot(xL2, color=yellow, title="L1")
plot(xL3, color=yellow, title="H2")
plot(xL4, color=yellow, title="L2")
longCondition1 = crossover(close, xL4)
if (longCondition1)
strategy.entry("l1", strategy.long)
longCondition2 = crossover(close, xL2)
if (longCondition2)
strategy.entry("l1", strategy.long)
shortCondition1 = crossover(close, xL1)
if (shortCondition1)
strategy.close("l1", strategy.long)
shortCondition2 = crossover(close, xL2)
if (shortCondition2)
strategy.close("l1", strategy.long)
shortCondition3 = crossover(close, xL3)
if (shortCondition3)
strategy.close("l1", strategy.long)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-03-01. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Quant-Trading-Strategy-Based-on-HullMA-Percentage-Bands.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- 5 Day Moving Average Channel Breakout Strategy Combined With Mileage ConceptPine Script · Breakout · 1d
- ATR Trailing Stops StrategyPine Script · Breakout · 1h
- ATR Trend Breakout StrategyPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Channel Breakout StrategyPine Script · Breakout · 1d
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h