OPEN-SOURCE SCRIPT
Divergence Detector (MACD + Volume)

Divergence Detector (MACD + Volume Confirmation)
This indicator automatically detects bullish and bearish divergences between price and MACD, enhanced with volume confirmation to filter out weak signals.
🔹 Core Logic
Pivot Detection:
The script identifies swing highs and lows (pivots) using customizable left/right lookback values.
Bullish Divergence:
Occurs when price makes a lower low, but MACD makes a higher low.
A label "Bull Div" appears below the bar; if confirmed by high volume, it shows "Bull Div 🔥".
Bearish Divergence:
Occurs when price makes a higher high, but MACD makes a lower high.
A label "Bear Div" appears above the bar; if confirmed by high volume, it shows "Bear Div 📉".
Volume Confirmation:
The indicator checks whether the volume at the pivot bar is above the moving average of volume (customizable length).
This ensures that divergence signals are backed by strong market participation.
Inputs
MACD Fast/Slow/Signal Length – standard MACD parameters
Pivot Lookback Left/Right – defines the swing structure sensitivity
Volume MA Length – defines how volume strength is validated
Output
Labels:
🔹 Bull Div / Bull Div 🔥 → Bullish divergence (confirmed with volume)
🔹 Bear Div / Bear Div 📉 → Bearish divergence (confirmed with volume)
Tips
Works best on higher timeframes and trending markets.
Volume confirmation helps filter false divergences in low liquidity conditions.
Combine with trend or structure indicators for better trade setups.
----------------------------------------------------------------------------------------------
اندیکاتور شناسایی واگرایی MACD با تأیید حجم
این اندیکاتور بهصورت خودکار واگراییهای صعودی و نزولی بین قیمت و MACD را شناسایی کرده و با استفاده از تأیید حجم (Volume Confirmation) سیگنالهای ضعیف را فیلتر میکند.
🔹 منطق عملکرد
شناسایی پیوتها:
نقاط چرخش (سقف و کف) با استفاده از تعداد کندلهای قابل تنظیم در دو سمت شناسایی میشوند.
واگرایی صعودی (Bullish):
زمانی که قیمت کف پایینتر و MACD کف بالاتر میسازد.
برچسب "Bull Div" در زیر کندل نمایش داده میشود؛ اگر حجم بالا باشد، با علامت 🔥 مشخص میگردد.
واگرایی نزولی (Bearish):
زمانی که قیمت سقف بالاتر و MACD سقف پایینتر میسازد.
برچسب "Bear Div" در بالای کندل نمایش داده میشود؛ اگر حجم بالا باشد، با 📉 مشخص میگردد.
تأیید حجم:
اگر حجم در کندل پیوت بالاتر از میانگین متحرک حجم باشد، سیگنال معتبرتر در نظر گرفته میشود.
تنظیمات ورودی
تنظیمات MACD (Fast, Slow, Signal)
پارامترهای شناسایی پیوت (Left / Right)
طول میانگین متحرک حجم (Volume MA Length)
خروجیها
Bull Div 🔥 / Bear Div 📉 برای واگراییهای تأییدشده با حجم
Bull Div / Bear Div برای واگراییهای بدون تأیید حجم
نکات کاربردی
بهترین عملکرد در تایمفریمهای بالا و بازارهای دارای روند
تأیید حجم به حذف سیگنالهای اشتباه در شرایط حجم پایین کمک میکند
برای دقت بیشتر، آن را با اندیکاتورهای روند یا ساختار ترکیب کنید
⚠️ Disclaimer:
This script is provided for educational and informational purposes only.
It does not constitute financial advice, and the author is not responsible for any financial losses caused by its use.
Always confirm signals with your own analysis and other tools before making trading decisions.
⚠️ توجه:
این اسکریپت صرفاً جهت آموزش و اطلاعرسانی طراحی شده و توصیه مالی یا سرمایهگذاری محسوب نمیشود.
نویسنده مسئول هیچگونه ضرر یا زیان احتمالی ناشی از استفاده از آن نیست.
لطفاً پیش از هر تصمیم معاملاتی، تحلیل شخصی خود را انجام داده و از این ابزار در کنار سایر ابزارهای تحلیل و مدیریت ریسک استفاده کنید.
This indicator automatically detects bullish and bearish divergences between price and MACD, enhanced with volume confirmation to filter out weak signals.
🔹 Core Logic
Pivot Detection:
The script identifies swing highs and lows (pivots) using customizable left/right lookback values.
Bullish Divergence:
Occurs when price makes a lower low, but MACD makes a higher low.
A label "Bull Div" appears below the bar; if confirmed by high volume, it shows "Bull Div 🔥".
Bearish Divergence:
Occurs when price makes a higher high, but MACD makes a lower high.
A label "Bear Div" appears above the bar; if confirmed by high volume, it shows "Bear Div 📉".
Volume Confirmation:
The indicator checks whether the volume at the pivot bar is above the moving average of volume (customizable length).
This ensures that divergence signals are backed by strong market participation.
Inputs
MACD Fast/Slow/Signal Length – standard MACD parameters
Pivot Lookback Left/Right – defines the swing structure sensitivity
Volume MA Length – defines how volume strength is validated
Output
Labels:
🔹 Bull Div / Bull Div 🔥 → Bullish divergence (confirmed with volume)
🔹 Bear Div / Bear Div 📉 → Bearish divergence (confirmed with volume)
Tips
Works best on higher timeframes and trending markets.
Volume confirmation helps filter false divergences in low liquidity conditions.
Combine with trend or structure indicators for better trade setups.
----------------------------------------------------------------------------------------------
اندیکاتور شناسایی واگرایی MACD با تأیید حجم
این اندیکاتور بهصورت خودکار واگراییهای صعودی و نزولی بین قیمت و MACD را شناسایی کرده و با استفاده از تأیید حجم (Volume Confirmation) سیگنالهای ضعیف را فیلتر میکند.
🔹 منطق عملکرد
شناسایی پیوتها:
نقاط چرخش (سقف و کف) با استفاده از تعداد کندلهای قابل تنظیم در دو سمت شناسایی میشوند.
واگرایی صعودی (Bullish):
زمانی که قیمت کف پایینتر و MACD کف بالاتر میسازد.
برچسب "Bull Div" در زیر کندل نمایش داده میشود؛ اگر حجم بالا باشد، با علامت 🔥 مشخص میگردد.
واگرایی نزولی (Bearish):
زمانی که قیمت سقف بالاتر و MACD سقف پایینتر میسازد.
برچسب "Bear Div" در بالای کندل نمایش داده میشود؛ اگر حجم بالا باشد، با 📉 مشخص میگردد.
تأیید حجم:
اگر حجم در کندل پیوت بالاتر از میانگین متحرک حجم باشد، سیگنال معتبرتر در نظر گرفته میشود.
تنظیمات ورودی
تنظیمات MACD (Fast, Slow, Signal)
پارامترهای شناسایی پیوت (Left / Right)
طول میانگین متحرک حجم (Volume MA Length)
خروجیها
Bull Div 🔥 / Bear Div 📉 برای واگراییهای تأییدشده با حجم
Bull Div / Bear Div برای واگراییهای بدون تأیید حجم
نکات کاربردی
بهترین عملکرد در تایمفریمهای بالا و بازارهای دارای روند
تأیید حجم به حذف سیگنالهای اشتباه در شرایط حجم پایین کمک میکند
برای دقت بیشتر، آن را با اندیکاتورهای روند یا ساختار ترکیب کنید
⚠️ Disclaimer:
This script is provided for educational and informational purposes only.
It does not constitute financial advice, and the author is not responsible for any financial losses caused by its use.
Always confirm signals with your own analysis and other tools before making trading decisions.
⚠️ توجه:
این اسکریپت صرفاً جهت آموزش و اطلاعرسانی طراحی شده و توصیه مالی یا سرمایهگذاری محسوب نمیشود.
نویسنده مسئول هیچگونه ضرر یا زیان احتمالی ناشی از استفاده از آن نیست.
لطفاً پیش از هر تصمیم معاملاتی، تحلیل شخصی خود را انجام داده و از این ابزار در کنار سایر ابزارهای تحلیل و مدیریت ریسک استفاده کنید.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.