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.
⚠️ توجه:
این اسکریپت صرفاً جهت آموزش و اطلاعرسانی طراحی شده و توصیه مالی یا سرمایهگذاری محسوب نمیشود.
نویسنده مسئول هیچگونه ضرر یا زیان احتمالی ناشی از استفاده از آن نیست.
لطفاً پیش از هر تصمیم معاملاتی، تحلیل شخصی خود را انجام داده و از این ابزار در کنار سایر ابزارهای تحلیل و مدیریت ریسک استفاده کنید.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.