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.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
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
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
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
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.