Tags:

The core idea of this strategy is to identify market trend directions by combining Hull moving average and average true range (ATR), and enter positions after the trend direction is confirmed. Specifically, it calculates the difference between the Hull moving averages of a certain period and the previous period. When the difference rises, it indicates a bullish trend; when the difference declines, it indicates a bearish trend. At the same time, the ATR index is used to determine the amplitude. It enters positions when the trend direction is confirmed and the amplitude keeps expanding.

This strategy mainly relies on two types of indicators: Hull moving average and ATR.

The Hull moving average is a trend-following indicator developed by American futures trader Alan Hull. Similar to moving averages, the Hull moving average has higher sensitivity and can capture price changes and trends faster. The strategy sets an adjustable parameter hullLength to control the period of the Hull moving average. By calculating the difference between the current period’s Hull MA and previous period’s, it determines the current price trend direction.

ATR stands for Average True Range. It reflects the amplitude of daily price fluctuations. When volatility increases, ATR rises; when volatility declines, ATR falls. The strategy sets parameters like atrLength and atrSmoothing to control the ATR calculation. And ATR is plotted on the chart as one reference for entries.

Specifically, the strategy logic is:

- Calculate current period Hull MA (hullLength) and previous period Hull MA.
- Calculate the difference: hullDiff = currentHullMA - previousHullMA
- When hullDiff > 0, it indicates a bullish trend. When hullDiff < 0, it indicates a bearish trend.
- Calculate ATR (atrLength) of a period as an amplitude benchmark.
- When bullish trend is identified and ATR > price > price of atrLength periods ago, go long. When bearish and ATR < price < price of atrLength periods ago, go short.
- Use the positive/negative of hullDiff to determine close signals.

The advantages of this strategy:

- Combining trend judgment and volatility index, it can enter positions when price trend is clear and volatility rises to avoid whipsaws in range-bound markets.
- Hull MA responds faster to price changes and can quickly identify new trend directions.
- ATR reflects market volatility and heat, providing guidance for entry timings.
- Multiple adjustable parameters can be optimized for best parameter combinations.

Some risks of this strategy:

- Both Hull MA and ATR cannot completely avoid false breakouts and thus holds the risk of being trapped.
- Improper parameter settings may lead to over-trading or insufficient sensitivity, undermining strategy efficacy.
- It cannot handle violent price actions like sharp spikes or crashes effectively.

Solutions:

- Set proper stop loss to avoid being trapped by false breakouts.
- Test and optimize parameters to fit different market environments.
- Suspend strategy when facing violent volatility.

There is still large room for optimization:

- Test different hullLength parameters to find the optimal settings for current markets.
- Test ATR period combinations to grasp market heat the best.
- Try different ATR smoothing methods to see which performs the best.
- Optimize entry conditions with other volatility indicators like Reaction combined with ATR.
- Optimize stop loss to avoid being trapped.

This strategy integrates the trend following capacity of Hull MA and the heat judgment ability of ATR. It enters positions when trend is confirmed and volatility rises to filter out some invalid signals. Further enhancement can be achieved by parameter optimization and better risk management. In summary, this strategy combines multiple factors of trend tracking and heat judgment. When parameters are fine-tuned, it can deliver good results.

/*backtest start: 2024-01-07 00:00:00 end: 2024-01-14 00:00:00 period: 10m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 // Hull cross and ATR strategy("Hull cross and ATR", shorttitle="H&ATR", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills=true, calc_on_every_tick=true, pyramiding=0) keh=input(title="Hull Length",defval=50) length = input(title="ATR Length", defval=50, minval=1) smoothing = input(title="ATR Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"]) p=input(ohlc4,title="Price data") n2ma=2*wma(p,round(keh/2)) nma=wma(p,keh) diff=n2ma-nma sqn=round(sqrt(keh)) n2ma1=2*wma(p[1],round(keh/2)) nma1=wma(p[1],keh) diff1=n2ma1-nma1 sqn1=round(sqrt(keh)) n1=wma(diff,sqn) n2=wma(diff1,sqn) ma_function(source, length) => if smoothing == "RMA" rma(p, length) else if smoothing == "SMA" sma(p, length) else if smoothing == "EMA" ema(p, length) else wma(p, length) plot(ma_function(tr(true), length), title = "ATR", color=black, transp=50) closelong = n1<n2 if (closelong) strategy.close("buy") closeshort = n1>n2 if (closeshort) strategy.close("sell") if (ma_function(tr(true), length)<p and p>p[length] and n1>n2) strategy.entry("buy", strategy.long, comment="BUY") if (ma_function(tr(true), length)>p and p<p[length] and n1<n2) strategy.entry("sell", strategy.short, comment="SELL")template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6