OPEN-SOURCE SCRIPT
Script_Algo - CCI Divergence Strategy

🚀 A simple but effective strategy based on CCI divergence.
📊 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.
⚙️ 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.
📈 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 +230% in 1.5 years.
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).
⚡ 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.
🛠️ Settings
CCI Length – defines how sensitive the CCI line is to price changes.
Bars to look for divergence – defines how many bars back to check for highs/lows.
ATR period & multiplier – used for stop loss adjustment.
EMA trend filter – can be enabled and customized for length.
🎨 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.
⚠️ Disclaimer
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 author of this strategy does not encourage anyone to use this algorithm and is not responsible for any financial losses resulting from its application.
Any decision to use this strategy is made solely by TradingView users and crypto exchange account owners.
✍️ 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!
📊 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.
⚙️ 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.
📈 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 +230% in 1.5 years.
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).
⚡ 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.
🛠️ Settings
CCI Length – defines how sensitive the CCI line is to price changes.
Bars to look for divergence – defines how many bars back to check for highs/lows.
ATR period & multiplier – used for stop loss adjustment.
EMA trend filter – can be enabled and customized for length.
🎨 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.
⚠️ Disclaimer
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 author of this strategy does not encourage anyone to use this algorithm and is not responsible for any financial losses resulting from its application.
Any decision to use this strategy is made solely by TradingView users and crypto exchange account owners.
✍️ 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!
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。