OPEN-SOURCE SCRIPT

Script_Algo - Div-to-Div CCI Strategy

202
📈 This strategy tries to catch market moves from one CCI divergence to the opposite CCI divergence in the trend direction. In many cases, this approach allows capturing long moves.
🛡️ In case the price still goes the wrong way, the strategy includes an ATR-based stop loss, which allows adapting to the current market volatility.

📚 For those unfamiliar with CCI:
The Commodity Channel Index (CCI) is a momentum-based oscillator used to identify overbought and oversold conditions.
It helps traders spot potential trend reversals or confirm trend strength by comparing the current price to its average over a period of time.

⚙️ How the Strategy Works

The script looks for divergence between the CCI line and the price:

📉 If the price updates a higher high, but CCI shows a lower high → this is a bearish signal.

📈 If the price updates a lower low, but CCI shows a higher low → this is a bullish signal.

🔄 When an opposite divergence appears, the script closes the current trade and opens a position in the other direction.

🛡️ To protect against deep losses, the strategy includes a stop loss based on ATR.

📊 For higher efficiency, the script also uses a trend filter based on EMA.

🛠️ Settings

CCI Length – defines how sensitive the CCI line is to price changes (default - 15).

Bars to look for divergence – defines how many bars back to check for highs/lows (default - 6).

ATR period & multiplier – used for stop loss adjustment (default - 14).

EMA trend filter – can be enabled and customized for length (default - 3).

Initial capital - 10000 $, position size - 1000, comission - 0,1%, risk per trade - 1%.

🎨 Visualization

📌 Signal markers for entries & exits are shown.

🟩 Light green background → when in a long position.

🟥 Light red background → when in a short position.

⬜ Light gray background → when no position is open.

📈 Backtest Results

✅ If you carefully check the backtest, you’ll see that on the DOTUSDT pair — a fairly conservative and reputable crypto asset — the strategy could potentially yield around 2300 $ in 1.5 years considering position size 1000$ and the small projected drawdown 400 $.

✅ Moreover, during a similar past period on the same asset, the strategy was also profitable.

✅ On the 1-hour timeframe, the equity curve shows stable growth.

✅ Win rate: 50%+

✅ Profit factor: ~2

👉 Whether this is good or bad — judge for yourself, considering that during this time DOT price dropped by 50% (from $8 to $4).

⚡ Always remember: past performance does not guarantee future results.
The market constantly changes, so you must monitor conditions, backtest, and adjust settings for each asset.

💡 Advice:

Be aware of possible bugs in any algo trading strategy, even if well-tested.

No one knows what unexpected events may occur on the market tomorrow.

Trade only on high-liquidity assets to avoid excessive volatility, high slippage, wide spreads, and commissions.

⚡ The script does not repaint. I personally tested the strategy multiple times in TradingView’s backtest mode across different assets on the 1H timeframe. Results may slightly differ due to slippage and sudden market moves.

📊 The script is ready for automated trading via webhook on any crypto exchange that supports this functionality.

⏳ Recommended Use

The strategy can be effective on many fundamentally strong and highly liquid assets. It is recommended to use a timeframe of 1H or higher.

⚠️ Disclaimer

Please note that the results of the strategy are not guaranteed to repeat in the future. The market constantly changes, and no algorithm can predict exactly how an asset will behave.
The author of this strategy is not responsible for any financial losses associated with using this script.
All trading decisions are made solely by the user.
Trading financial markets carries high risks and can lead to loss of your investments.

Before using the strategy, it is strongly recommended to:
✅ Backtest the strategy on historical data
✅ Start with small trading volumes
✅ Use only risk capital you are ready to lose
✅ Fully understand how the strategy works

✍️ Final Notes

💡 If you have any ideas on how to improve this or my other strategies, feel free to let me know — I’ll try to implement them.

🐞 If you notice any bugs or inconsistencies in my algorithm, please write to me — I hope to fix them as soon as possible.

⚡ This is not the final version of the strategy.
I am constantly working on optimization and efficiency improvements, so follow me to not miss updates.

💰 Good luck and stable profits to everyone!

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.