OPEN-SOURCE SCRIPT

Triple CCI Strategy MFI Confirmed [Skyrexio]

Overview
Triple CCI Strategy MFI Confirmed [Skyrexio] leverages 3 different periods Commodity Channel Index (CCI) indicator in conjunction Money Flow Index (MFI) and Exponential Moving Average (EMA) to obtain the high probability setups. Fast period CCI is used for having the high probability to enter in the direction of short term trend, middle and slow period CCI are used for confirmation, if market now likely in the mid and long-term uptrend. MFI is used to confirm trade with the money inflow/outflow with the high probability. EMA is used as an additional trend filter. Moreover, strategy uses exponential moving average (EMA) to trail the price when it reaches the specific level. More information in "Methodology" and "Justification of Methodology" paragraphs. 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. Four layers trade filtering system: Strategy utilizes two different period CCI indicators, MFI and EMA indicators to confirm the signals produced by fast period CCI.
  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. Fast period CCI shall crossover the zero-line.
  2. Slow and Middle period CCI shall be above zero-lines.
  3. Price shall close above the EMA. Crossover is not obligatory
  4. MFI shall be above 50


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 = 14, used for calculation short term period CCI)
  4. CCI Middle Length (by default = 25, used for calculation short term period CCI)
  5. CCI Slow Length (by default = 50, used for calculation long term period CCI)
  6. MFI Length (by default = 14, used for calculation MFI
  7. EMA Length (by default = 50, period of EMA, used for trend filtering EMA calculation)
  8. 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, MFI and EMA.

The Commodity Channel Index (CCI) is a momentum-based technical indicator that measures the deviation of a security's price from its average price over a specific period. It helps traders identify overbought or oversold conditions and potential trend reversals.
The CCI formula is:
CCI = (Typical Price − SMA) / (0.015 × Mean Deviation)

  1. Typical Price (TP): This is calculated as the average of the high, low, and closing prices for the period.
  2. Simple Moving Average (SMA): This is the average of the Typical Prices over a specific number of periods.
  3. 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 Money Flow Index (MFI) is a technical indicator that measures the strength of money flowing into and out of a security. It combines price and volume data to assess buying and selling pressure and is often used to identify overbought or oversold conditions. The formula for MFI involves several steps:

1. Calculate the Typical Price (TP):
TP = (high + low + close) / 3

2. Calculate the Raw Money Flow (RMF):
Raw Money Flow = TP × Volume

3. Determine Positive and Negative Money Flow:
  • If the current TP is greater than the previous TP, it's Positive Money Flow.
  • If the current TP is less than the previous TP, it's Negative Money Flow.


4. Calculate the Money Flow Ratio (MFR):
Money Flow Ratio = Sum of Positive Money Flow (over n periods) / Sum of Negative Money Flow (over n periods)

5. Calculate the Money Flow Index (MFI):
MFI = 100 − (100 / (1 + Money Flow Ratio))

MFI above 80 can be considered as overbought, below 20 - oversold.

The Exponential Moving Average (EMA) is a type of moving average that places greater weight and significance on the most recent data points. It is widely used in technical analysis to smooth price data and identify trends more quickly than the Simple Moving Average (SMA).
​Formula:
1. Calculate the multiplier
Multiplier = 2 / (n + 1), Where n is the number of periods.

2. EMA Calculation
EMA = (Current Price) × Multiplier + (Previous EMA) × (1 − Multiplier)

This strategy leverages Fast period CCI, which shall break the zero line to the upside to say that probability of short term trend change to the upside increased. This zero line crossover shall be confirmed by the Middle and Slow periods CCI Indicators. At the moment of breakout these two CCIs shall be above 0, indicating that there is a high probability that price is in middle and long term uptrend. This approach increases chances to have a long trade setup in the direction of mid-term and long-term trends when the short-term trend starts to reverse to the upside.

Additionally strategy uses MFI to have a greater probability that fast CCI breakout is confirmed by this indicator. We consider the values of MFI above 50 as a higher probability that trend change from downtrend to the uptrend is real. Script opens long trades only if MFI is above 50. As you already know from the MFI description, it incorporates volume in its calculation, therefore we have another one confirmation factor.

Finally, strategy uses EMA an additional trend filter. It allows to open long trades only if price close above EMA (by default 50 period). It increases the probability of taking long trades only in the direction of the trend.

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 another one EMA (by default = 20 period) as a trailing profit level.

Backtest Results
  • Operating window: Date range of backtests is 2022.04.01 - 2024.11.25. 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: 50%
  • Maximum Single Position Loss: -4.13%
  • Maximum Single Profit: +19.66%
  • Net Profit: +5421.21 USDT (+54.21%)
  • Total Trades: 108 (44.44% win rate)
  • Profit Factor: 2.006
  • Maximum Accumulated Loss: 777.40 USDT (-7.77%)
  • Average Profit per Trade: 50.20 USDT (+0.85%)
  • Average Trade Duration: 44 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


cciindicatorCommodity Channel Index (CCI)Exponential Moving Average (EMA)MFIMoney Flow Index (MFI)moving_average

开源脚本

本着真正的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
更多:

免责声明