OPEN-SOURCE SCRIPT

Source-Aligned Oscillators (for Divergences)

2 530
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:
  • 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. Подробнее читайте в Условиях использования.