OPEN-SOURCE SCRIPT
Source-Aligned Oscillators (for Divergences)

A simple tool to visualize oscillators on different price sources — and fix one of the most common divergence mistakes.
Many traders look for divergence by comparing:
This creates a hidden inconsistency.
Oscillators such as Relative Strength Index, momentum, or ROC are typically built using close-to-close data.
But when divergence is drawn using wick extremes (highs/lows), you are no longer comparing the same type of information.
This becomes especially problematic on large candles:
👉 This often produces “fake” or misleading divergence signals.
The idea behind this script
Divergence should ideally be evaluated using aligned data sources:
This script allows you to do exactly that.
What this tool does
Displays a single oscillator at a time for clarity
Supports multiple oscillators:
Lets you compute them on different sources:
High / Low split mode (key feature)
Instead of forcing one source, this mode shows:
This helps you clearly see how oscillators behave when aligned with actual price extremes — instead of mixing closes with wicks.
How to use it
Final note
This tool does not generate divergence signals automatically.
Its purpose is to help you see divergence correctly, with consistent data.
Because sometimes the issue is not the market — it is how we measure it.
Many traders look for divergence by comparing:
- price → using highs and lows
- oscillators (like RSI) → calculated on close
This creates a hidden inconsistency.
Oscillators such as Relative Strength Index, momentum, or ROC are typically built using close-to-close data.
But when divergence is drawn using wick extremes (highs/lows), you are no longer comparing the same type of information.
This becomes especially problematic on large candles:
- the distance between low and close (or high and close) can be significant
- price may print a new low via a wick
- while the close — and therefore the oscillator — shows little real change
👉 This often produces “fake” or misleading divergence signals.
The idea behind this script
Divergence should ideally be evaluated using aligned data sources:
- if your oscillator is based on closes → compare it to close-based structure
- if you want to use highs/lows → then the oscillator should reflect those extremes too
This script allows you to do exactly that.
What this tool does
Displays a single oscillator at a time for clarity
Supports multiple oscillators:
- RSI
- ROC
- Momentum
- MACD Histogram
- CMO
- Stochastic RSI
Lets you compute them on different sources:
- Close
- HL2
- HLC3
- OHLC4
- Candle body split (open/close extremes)
- High / Low split
High / Low split mode (key feature)
Instead of forcing one source, this mode shows:
- oscillator calculated on lows → useful for bullish structure
- oscillator calculated on highs → useful for bearish structure
This helps you clearly see how oscillators behave when aligned with actual price extremes — instead of mixing closes with wicks.
How to use it
- Switch between sources and observe how oscillator structure changes
- Compare close-based vs wick-based behavior
- Identify whether a divergence is:
- structurally meaningful
- or simply caused by a single candle wick
Final note
This tool does not generate divergence signals automatically.
Its purpose is to help you see divergence correctly, with consistent data.
Because sometimes the issue is not the market — it is how we measure it.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Quant Developer | Pine Script v6 | Python & R
12+ yrs system. trading, hedge fund experience
Indicators, strategies & screeners
Futures & options
💼 Hire/Consulting:
qntly.com/hire
🎓 Pine Code With AI:
qntly.com/pineai
12+ yrs system. trading, hedge fund experience
Indicators, strategies & screeners
Futures & options
💼 Hire/Consulting:
qntly.com/hire
🎓 Pine Code With AI:
qntly.com/pineai
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Quant Developer | Pine Script v6 | Python & R
12+ yrs system. trading, hedge fund experience
Indicators, strategies & screeners
Futures & options
💼 Hire/Consulting:
qntly.com/hire
🎓 Pine Code With AI:
qntly.com/pineai
12+ yrs system. trading, hedge fund experience
Indicators, strategies & screeners
Futures & options
💼 Hire/Consulting:
qntly.com/hire
🎓 Pine Code With AI:
qntly.com/pineai
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.