OPEN-SOURCE SCRIPT

Double CCI Confirmed Hull Moving Average Reversal Strategy

Overview
The Double CCI Confirmed Hull Moving Average Strategy utilizes hull moving average (HMA) in conjunction with two commodity channel index (CCI) indicators: the slow and fast to increase the probability of entering when the short and mid-term uptrend confirmed. The main idea is to wait until the price breaks the HMA while both CCI are showing that the uptrend has likely been already started. Moreover, strategy uses exponential moving average (EMA) to trail the price when it reaches the specific level. The strategy opens only long trades.

Unique Features
  1. Dynamic stop-loss system: Instead of fixed stop-loss level strategy utilizes average true range (ATR) multiplied by user given number subtracted from the position entry price as a dynamic stop loss level.
  2. Configurable Trading Periods: Users can tailor the strategy to specific market windows, adapting to different market conditions.
  3. Double trade setup confirmation: Strategy utilizes two different period CCI indicators to confirm the breakouts of HMA.
  4. Trailing take profit level: After reaching the trailing profit activation level scrip activate the trailing of long trade using EMA. More information in methodology.


Methodology
The strategy opens long trade when the following price met the conditions:
  1. Short-term period CCI indicator shall be above 0.
  2. Long-term period CCI indicator shall be above 0.
  3. Price shall cross the HMA and candle close above it with the same candle


When long trade is executed, strategy set the stop-loss level at the price ATR multiplied by user-given value below the entry price. This level is recalculated on every next candle close, adjusting to the current market volatility.
At the same time strategy set up the trailing stop validation level. When the price crosses the level equals entry price plus ATR multiplied by user-given value script starts to trail the price with EMA. If price closes below EMA long trade is closed. When the trailing starts, script prints the label “Trailing Activated”.

Strategy settings
In the inputs window user can setup the following strategy settings:
  1. ATR Stop Loss (by default = 1.75)
  2. ATR Trailing Profit Activation Level (by default = 2.25)
  3. CCI Fast Length (by default = 25, used for calculation short term period CCI
  4. CCI Slow Length (by default = 50, used for calculation long term period CCI)
  5. Hull MA Length (by default = 34, period of HMA, which shall be broken to open trade)
  6. Trailing EMA Length (by default = 20)


User can choose the optimal parameters during backtesting on certain price chart.

Justification of Methodology
Before understanding why this particular combination of indicator has been chosen let's briefly explain what is CCI and HMA.

The Commodity Channel Index (CCI) is a momentum-based technical indicator used in trading to measure a security's price relative to its average price over a given period. Developed by Donald Lambert in 1980, the CCI is primarily used to identify cyclical trends in a security, helping traders to spot potential buying or selling opportunities.

The CCI formula is:
CCI = (Typical Price − SMA) / (0.015 × Mean Deviation)

  • Typical Price (TP): This is calculated as the average of the high, low, and closing prices for the period.
  • Simple Moving Average (SMA): This is the average of the Typical Prices over a specific number of periods.
  • Mean Deviation: This is the average of the absolute differences between the Typical Price and the SMA.


The result is a value that typically fluctuates between +100 and -100, though it is not bounded and can go higher or lower depending on the price movement.

The Hull Moving Average (HMA) is a type of moving average that was developed by Alan Hull to improve upon the traditional moving averages by reducing lag while maintaining smoothness. The goal of the HMA is to create an indicator that is both quick to respond to price changes and less prone to whipsaws (false signals).

How the Hull Moving Average is Calculated?
The Hull Moving Average is calculated using the following steps:
  • Weighted Moving Average (WMA): The HMA starts by calculating the Weighted Moving Average (WMA) of the price data over a period square root of n (sqrt(n))
  • Speed Adjustment: A WMA is then calculated for half of the period n/2, and this is multiplied by 2 to give more weight to recent prices.
  • Lag Reduction: The WMA of the full period n is subtracted from the doubled n/2 WMA.
  • Final Smoothing: To smooth the result and reduce noise, a WMA is calculated for the square root of the period n.


The formula can be represented as:
HMA(n) = WMA(WMA(n/2) × 2 − WMA(n), sqrt(n))

The Weighted Moving Average (WMA) is a type of moving average that gives more weight to recent data points, making it more responsive to recent price changes than a Simple Moving Average (SMA). In a WMA, each data point within the selected period is multiplied by a weight, with the most recent data receiving the highest weight. The sum of these weighted values is then divided by the sum of the weights to produce the WMA.

This strategy leverages HMA of user given period as a critical level which shall be broken to say that probability of trend change to the upside increased. HMA reacts faster than EMA or SMA to the price change, that’s why it increases chances to enter new trade earlier. Long-term period CCI helps to have an approximation of mid-term trend. If it’s above 0 the probability of uptrend increases. Short-period CCI allows to have an approximation of short-term trend reversal from down to uptrend. This approach increases chances to have a long trade setup in the direction of mid-term trend when the short-term trend starts to reverse.

ATR is used to adjust the strategy risk management to the current market volatility. If volatility is low, we don’t need the large stop loss to understand the there is a high probability that we made a mistake opening the trade. User can setup the settings ATR Stop Loss and ATR Trailing Profit Activation Level to realize his own risk to reward preferences, but the unique feature of a strategy is that after reaching trailing profit activation level strategy is trying to follow the trend until it is likely to be finished instead of using fixed risk management settings. It allows sometimes to be involved in the large movements. It’s also important to make a note, that script uses HMA to enter the trade, but for trailing it leverages EMA. It’s used because EMA has no such fast reaction to price move which increases probability not to be stopped out from any significant uptrend move.

Backtest Results
  • Operating window: Date range of backtests is 2022.07.01 - 2024.08.01. It is chosen to let the strategy to close all opened positions.
  • Commission and Slippage: Includes a standard Binance commission of 0.1% and accounts for possible slippage over 5 ticks.
  • Initial capital: 10000 USDT
  • Percent of capital used in every trade: 100%
  • Maximum Single Position Loss: -4.67%
  • Maximum Single Profit: +19.66%
  • Net Profit: +14897.94 USDT (+148.98%)
  • Total Trades: 104 (36.54% win rate)
  • Profit Factor: 2.312
  • Maximum Accumulated Loss: 1302.66 USDT (-9.58%)
  • Average Profit per Trade: 143.25 USDT (+0.96%)
  • Average Trade Duration: 34 hours

These results are obtained with realistic parameters representing trading conditions observed at major exchanges such as Binance and with realistic trading portfolio usage parameters.

How to Use
Add the script to favorites for easy access.
Apply to the desired timeframe and chart (optimal performance observed on 2h BTC/USDT).
Configure settings using the dropdown choice list in the built-in menu.
Set up alerts to automate strategy positions through web hook with the text: {{strategy.order.alert_message}}

Disclaimer:
Educational and informational tool reflecting Skyrex commitment to informed trading. Past performance does not guarantee future results. Test strategies in a simulated environment before live implementation
ATRcciindicatorcommoditychannelCommodity Channel Index (CCI)Exponential Moving Average (EMA)HMAHull Moving Average (HMA)

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?


Get access to private PineScript strategies and turn script alerts into orders at your exchange account with easy-to-set up bots

Get free alert bot:
skyrexio.com

Get 50% Black Friday discount with promo code: BF50
他のメディア:

免責事項