Any Oscillator Overlay [TGPT]

1 144
This indicator projects any oscillator's key levels — midpoint, signal lines, overbought/oversold zones — directly onto the price chart. Tested with RSI, MACD, CCI, Stochastic, Williams %R, and many others, including custom oscillators — without needing to know their internal formula.

The Problem

Traders watch oscillators for midpoint crosses (usually, zero line or 50), overbought/oversold zone entries, and signal line crosses. A cross in the oscillator pane tells you when momentum flipped — but not what price was actually doing at that moment. How many of those crosses happened while price was chopping inside a range, with the oscillator hovering near its midpoint? How many were immediately reversed? How deep did price wick through the oscillator level before recovering? None of this is visible in the oscillator pane. It requires switching back and forth between panes and mentally reconstructing each event in context.

This indicator attempts to collapse those two coordinate systems into one. When oscillator levels are projected onto the price chart, interpretation becomes immediate: you can more clearly see whether a zero cross coincided with a clean directional move or with indecisive ranging; whether price respected the projected signal line or sliced through it repeatedly; whether wicks are constantly piercing overbought and oversold levels — the kind of behavior that looks seemingly clean or unnoticeable in the oscillator pane but tells a different story when projected onto price. Context that would otherwise require mentally switching between panes is visible at a glance across the entire chart history.

The goal is not to replace the oscillator pane. It is to make oscillator behavior readable and interpretable on the price chart itself — something that is usually impossible without knowing the oscillator's internal formula, and often difficult even then.

What makes this possible without being tied to any specific oscillator is a universal normalization method that operates purely on the oscillator's output — no knowledge of its internal formula required. This is what separates this approach from oscillator-specific overlays. The reconstruction works on any oscillator; the visual defaults — overbought/oversold zones, signal line, midpoint conventions — are tuned for what is commonly watched on momentum oscillators, and can be adjusted for other cases.

Prior Approaches

Prior overlay approaches plot the oscillator as a scaled visual proxy positioned above or below price action — the oscillator's values are mapped into the recent high/low price range, then offset from price entirely to avoid interfering with it. This is a deliberate and honest design choice: the projection is treated as a display convenience, not a coordinate transform. The visual sits near price but remains a separate pane in spirit.

Some implementations skip the offset entirely and overlay the rescaled oscillator directly on the candles. Without a meaningful coordinate transform this creates visual noise — the line intersects price arbitrarily, crossovers mean nothing, and the result is harder to read than the original oscillator pane.

The approach here takes the problem seriously as a coordinate transform: oscillator levels are projected directly onto price with structural exactness. When the oscillator crosses zero or its signal line, price crosses the corresponding reconstructed line. The levels are stable across all market conditions and work identically regardless of which oscillator is connected.

How It Works

Projecting an oscillator onto the price chart requires answering one question at every bar:

"What price level corresponds to this oscillator's key levels right now?"

This is a coordinate transform problem. Oscillator units vary by type — RSI is in percentage points, CCI in deviation units, MACD in price difference units. Price lives in its own space. Attempting a direct reconstruction produces wild instability — projected lines flying off the chart, collapsing to a point, or jittering unpredictably as the underlying relationship between oscillator and price shifts. Filtering or smoothing the oscillator values might help avoid the instability but would produce an inaccurate reconstruction — at that point it is a different signal altogether, not the oscillator's levels projected onto price. There is no universal closed-form inversion between the two without knowing the oscillator's internal formula.

The approach implemented here — z-score normalization mapped to price standard deviation — solves the explosion problem mathematically rather than by filtering or smoothing.

Universality — Why Any Oscillator Works

Most oscillator overlay attempts are oscillator-specific. They work by exploiting knowledge of the oscillator's internal formula — for example, knowing that an oscillator is derived from a specific price transform, one can algebraically invert it back into a price level. This approach is precise but narrow: it breaks entirely when applied to a different oscillator, and does not work at all for oscillators not derived from price.

This indicator achieves universality by operating exclusively on the output of the oscillator — the plotted series — without any knowledge of or assumption about its internal construction. This is possible because of two observations:

Observation 1: Most oscillators share a common structural grammar.

Regardless of how they are computed, most oscillators share a common behavioral structure: they oscillate around a reference level (typically zero or 50), they have a signal line (typically a moving average of themselves), and their distance from that reference reflects the strength of the underlying signal. RSI oscillates around 50, CCI around 0, Stochastic around 50 — the absolute scale differs but the grammar is identical.

The z-score transform (osc / stdev(osc)) maps any oscillator's output into this common grammar, expressed in standard deviation units. After normalization, a reading of +1 means the same thing regardless of whether the source was RSI, CCI, or a custom oscillator: the oscillator is one standard deviation above its recent mean. The native scale — percentage points, index units, or whatever it may be — is completely abstracted away.

Observation 2: Price volatility is the natural unit of price-space distance.

Once the oscillator is in z-score units, it needs to be mapped to a price distance. The natural unit for price distance is the price series' own standard deviation — stdev(close, N). This is not an arbitrary choice: the standard deviation of price is the statistical measure of how much price typically moves over the same window used to normalize the oscillator. Mapping one oscillator σ to one price σ creates a dimensionally consistent relationship that self-calibrates to any instrument (BTC/USDT, EUR/USD, SPX, a penny stock) and any timeframe (1-minute, daily, weekly) without any manual scaling.

The product of these two observations is the core formula:

Pine Script®


This formula has no hard-coded constants specific to any oscillator. No lookup tables, no conditional branches for different oscillator types, no instrument-specific parameters. Its inputs are: the oscillator's output series, the price series, a window length, and a sensitivity multiplier. Given any oscillator series as input, it produces a geometrically consistent price-space projection.

The only assumption made is that the oscillator's zero line (or midpoint) represents momentum equilibrium — a condition that holds across all momentum oscillators by design. For bounded oscillators like RSI or Stochastic where equilibrium is at 50 rather than 0, the Oscillator midpoint parameter shifts the reference accordingly. Internally, (osc − midpoint) is normalized rather than osc directly — so setting midpoint to 50 makes the zero line correspond to RSI = 50, and the signal line to RSI signal crossovers, with no other changes required.

Because the method works purely on the output series, it is not even limited to oscillators in the strict sense. Any zero-based or midpoint-based series — exchange funding rates, open interest deltas, custom composite signals — can be projected onto price through the same formula. An example using funding rate is shown further down in Creative Uses.

As noted earlier, the reconstruction itself is universal. Visual conventions (fills, colors, zones) may need adjustment for oscillators outside the typical momentum family — ADX, for example, benefits from different fill and color logic — but the underlying projection works without modification.

Below is MACD on BTCUSDT weekly, with the MACD histogram zero line projected onto price. Settings: Oscillator source: MACD Histogram, Normalization window: 26 (matching MACD slow length), Midpoint: 0.

snapshot

Below is Williams %R on BTCUSDT weekly, with the midpoint and overbought/oversold zones projected onto price. Settings: Oscillator source: Williams %R, Normalization window: 14 (matching Williams %R length), Midpoint: −50, Overbought level / extreme: −20 / 0, Oversold level / extreme: −80 / −100.

snapshot

Below is CCI on BTCUSDT weekly, with the CCI zero line projected onto price. Settings: Oscillator source: CCI, Normalization window: 20 (matching CCI length), Midpoint: 0.

snapshot

The Math

Step 1 — Z-Score Normalization

Pine Script®


The oscillator is divided by its own rolling standard deviation over window N. This converts any oscillator — regardless of its native scale — into standard deviation units (z-score). The result is dimensionless and bounded in practice: z-scores beyond ±6 are statistically rare and are hard-clamped to prevent outlier distortion.

This solves the scale problem: RSI, CCI, and any custom oscillator all produce a normalized value in the same [−6, +6] range, making the subsequent price mapping universal.

Step 2 — Price Standard Deviation Mapping

Pine Script®


The normalized oscillator is multiplied by the price series' own standard deviation (scaled by a user-controlled sensitivity factor, 1.0 by default). This maps one unit of oscillator z-score to one standard deviation of price movement — a dimensionally consistent relationship.

When the oscillator is at its midpoint (oscNorm = 0), zeroLine = close exactly. The zero line sits on price. When the oscillator is at +1σ (oscNorm = 1), the zero line sits one price standard deviation below close, reflecting that price is one sigma above its momentum equilibrium. The distance is always expressed in the instrument's own volatility units — no arbitrary scaling.

Why it cannot explode. Given that reconstructing an oscillator in price space is prone to the kind of wild instability described earlier, it is worth stating explicitly why this formulation is well-behaved. There is no division by a potentially-zero slope. The denominator oscStd is non-negative, and the zero case (a constant oscillator) is handled explicitly rather than dividing. The product oscNorm × step is bounded by 6 × priceStd × sensitivity — a finite, always-defined quantity.

Step 3 — Signal Line Reconstruction

Pine Script®


When osc = sigSrc (a crossover), diff = 0, diffNorm = 0, and sigLine = close. The signal line sits on price at the moment of a crossover, exactly as the zero line sits on price at a zero crossing. This is the correct structural equivalence.

Using osc − sigSrc rather than normalizing sigSrc directly is important: it measures the gap between oscillator and signal, which is the quantity that crosses zero on a signal crossover — not the signal's absolute level.

A second signal line is supported through the same construction. This is primarily useful for custom oscillators with two independent signal sources, or for advanced setups — for example, applying an external moving average to the oscillator and feeding that back in as a second signal. The reconstruction treats each signal as its own osc − sigSrc gap and projects it accordingly.

What Else You Can Read From It

Volatility-Normalized Distance

One practical benefit of projecting oscillator levels onto price is that the visual gap between price and the zero line becomes a direct, volatility-adjusted reading of momentum strength — something the oscillator pane does not provide.

In the oscillator pane, a reading of RSI 60 occupies the same visual distance from 50 whether the market is in a tight consolidation or a wide trending move. The absolute value looks identical across different volatility regimes. On the overlay, the same reading produces a larger or smaller gap depending on priceStd at that moment — the distance self-scales to current market conditions. A wide gap signals that momentum is far from equilibrium relative to how much price is actually moving. A narrow gap signals that momentum is near neutral relative to current volatility, even if the raw oscillator number appears elevated.

This makes the overlay useful not just for identifying crossover events but for assessing their weight. A zero line cross accompanied by a wide, expanding gap carries different context than one where price and the zero line have been trading close together — the former reflects a genuine momentum shift in the context of active price movement, the latter may reflect a cross in a low-energy, low-conviction environment.

The EMA Layer

The optional EMA of the zero line is a different signal from the zero line itself.

In the oscillator pane, an EMA of the zero line is a constant — the EMA of a fixed level carries no information. On the price chart, the zero line is not fixed: it drifts with price as momentum conditions change. An EMA of that drifting series tracks where momentum equilibrium has been spending its time in price space over the EMA window — a smoothed reference for recent neutral momentum.

This creates two distinct signals:

  • Zero line — where momentum equilibrium is right now, bar by bar.
  • EMA of zero line — where momentum equilibrium has been on average over the recent window. A slowly rising EMA indicates the neutral momentum level has been drifting upward in price space — consistent with a gradual bullish bias. It can also help filter noise: a zero line cross that does not pull the EMA in the same direction may reflect a low-conviction move that is unlikely to develop into a sustained shift.


Creative Uses

The reconstruction does not care whether the input series is a traditional oscillator. Any zero-based or midpoint-based series can be used as a source and projected onto price through the same formula. A practical example is exchange funding rate: a zero-based series that reflects perpetual futures positioning, with no built-in signal line of its own.

The setup below uses an indicator-on-indicator trick that TradingView supports natively. First, a standard EMA is applied to the funding rate series in its own pane (an indicator applied to another indicator). Then, in Any Oscillator Overlay, funding rate is selected as the oscillator source and the EMA of funding rate is selected as Signal source 1. The overlay projects the gap between the two onto price — so when funding rate crosses its EMA, price crosses the projected signal line exactly. Only the signal line is visualized here; the midpoint is disabled to keep the chart focused on the crossover events.

Below is ETHUSDT.P 1h with Binance funding rate as the oscillator source and an EMA(15) of funding rate as the signal line. Settings: Oscillator source: Funding Rate, Signal source 1: EMA(15) of Funding Rate, Midpoint: 0, Midpoint line: hidden, Signal Line 1: visible.

snapshot

Parameters

General

  • Oscillator source — Select the main plot of your oscillator. Accepts any series regardless of native scale: MACD, RSI, CCI, Stochastic, volume-based oscillators, or any custom oscillator.
  • Signal source 1 — The oscillator's signal line. If your oscillator has no signal line, leave as close and keep the signal line hidden (hidden by default).
  • Signal source 2 — Optional second signal line. Useful for custom oscillators with two independent signal sources, or for advanced setups like feeding an external EMA of the oscillator back in as a signal. Leave as close and hide if not needed.
  • Oscillator midpoint — The oscillator value representing momentum equilibrium. 0 for zero-based oscillators (MACD, CCI). 50 for bounded oscillators (RSI, Stochastic, MFI).
  • Normalization window — Rolling window for stdev(osc) and stdev(close). Range: 10–2000. Longer = more structural, slower to adapt. Shorter = more reactive, noisier levels. Match to your oscillator's primary lookback length.
  • Sensitivity — Multiplier on priceStd. At 1.0, one oscillator σ maps to one price σ. Increase to widen spacing between levels; decrease to tighten. Range: 0.1–5.0. Does not affect crossover accuracy.
  • Z-score clamp — Maximum z-score before hard clamping. Default 6.0. Increase if overbought/oversold lines behave unreliably — this happens when the oscillator's standard deviation is small relative to the distance to OB/OS levels.


Midpoint

  • Line — Projects the oscillator's midpoint (zero line or 50) onto price. When the oscillator crosses its midpoint, price crosses this line exactly. Bull/bear color by price position relative to the line.
  • Fill — Fills the area between price and the projected midpoint. Bull color when price is above, bear color when below.
  • EMA — Optional EMA of the projected midpoint. Length is configurable. Tracks where momentum equilibrium has been drifting in price space. Bull/bear color by price position.
  • EMA fill — Fills the area between price and the midpoint EMA.


Signal Line 1 / Signal Line 2

  • Line — Projects the signal line crossover level onto price. When the oscillator crosses its signal line, price crosses this line exactly. Bull/bear color by price position.
  • Fill — Fills the area between price and the projected signal line.
  • EMA — Smoothed version of the signal line. Length is configurable. A slower-moving reference for where recent crossover activity has been centered.
  • EMA fill — Fills the area between price and the signal line EMA.


Overbought / Oversold Zones

  • Overbought level / extreme — Level: the oscillator value considered overbought (e.g. 70 for RSI, 100 for CCI). Extreme: the oscillator's absolute maximum (e.g. 100 for RSI). The fill zone spans between these two projected levels when price is inside that zone.
  • Overbought line — Shows the projected overbought level line. If it behaves unreliably, increase the Z-score clamp.
  • Overbought fill — Fills the zone between the overbought level and extreme only when price is inside that zone.
  • Oversold level / extreme — Level: the oscillator value considered oversold (e.g. 30 for RSI, −100 for CCI). Extreme: the oscillator's absolute minimum (e.g. 0 for RSI).
  • Oversold line — Shows the projected oversold level line.
  • Oversold fill — Fills the zone between the oversold level and extreme only when price is inside that zone.


Setup

RSI is a good starting point for getting familiar with the indicator. Add it to the chart, connect it as the oscillator source, set the midpoint to 50, and the zero line will immediately track RSI's equilibrium level on price. Connect the signal line. Toggle overbought/oversold on. The same approach then generalizes to any oscillator.

  1. Add your oscillator of choice to the chart
  2. Add Any Oscillator Overlay [TGPT] to the same chart
  3. In indicator settings → Oscillator source: select the main plot of your oscillator
  4. In indicator settings → Signal source 1: select the signal line plot of your oscillator (hidden by default; leave as close and keep hidden if no signal exists)
  5. Set Oscillator midpoint to match your oscillator's neutral level (0 for CCI/MACD, 50 for RSI/Stochastic). Setting this incorrectly will produce a meaningless reconstruction
  6. Tune Normalization window to match your oscillator's primary lookback length
  7. Adjust Sensitivity until zero and signal lines feel proportionally spaced relative to typical price movement on your instrument. The default of 1.0 works well on most oscillators
  8. If OB/OS levels look unreliable on the chart, increase the Z-score clamp


Limitations

Intended use. This indicator is intended for reading trend context, zero line crosses, signal line crosses, and overbought/oversold level monitoring. Zero and signal line crosses are structurally exact: when the oscillator crosses zero or its signal line, price crosses the corresponding reconstructed line with no approximation. Overbought/oversold levels are reliable when the Z-score clamp is set appropriately — if OB/OS lines appear to behave unreliably, increase the Z-score clamp in General settings.

Divergence detection is outside the scope of this indicator. Detecting divergence requires precise comparison of price and oscillator pivots — a problem sensitive to source consistency and pivot detection methodology. The z-score normalization used here adds a volatility layer that can mask or exaggerate pivot differences, making it unsuitable for divergence analysis. Dedicated divergence tools should be used instead.

The mapping is exact but the relationship it encodes is a modeling choice. The computation is precise — the zero line is always exactly where the formula places it. What the formula encodes is a specific assumption: one oscillator standard deviation maps to one price standard deviation. This is a principled choice, not a mathematical inversion of the oscillator's internal formula, and like any modeling assumption it carries trade-offs. Similar trade-offs are present in virtually every technical indicator. Critically, crossover events are unaffected: when the oscillator crosses zero or its signal line, the reconstructed line crosses price exactly, regardless of the scaling assumption.

Normalization window sensitivity. The choice of N affects both the oscillator normalization and the price mapping. A window that is too short may produce unstable stdev estimates; a window too long may lag structural changes in volatility. There is no universally optimal value — match it to the oscillator's own primary lookback length.

Repainting. This indicator does not repaint by itself — it is a wire, transforming whatever is fed into it from the oscillator pane to the price pane. If the source oscillator repaints, you will see that behavior here as well; if it does not, neither will this.

Educational Use

Beyond live analysis, this indicator is a practical tool for building intuition about oscillator behavior. By loading historical data and attaching any oscillator, a trader can immediately audit how reliable a given crossover strategy has actually been on that instrument — visually, on the price chart. How often did the zero cross coincide with a sustained move? How frequently did price wick through the projected signal line and reverse? Were overbought levels actually respected, or did price spend extended time above them? These questions are answerable at a glance in a way the oscillator pane alone does not allow.

Once oscillator levels live on the price pane, they can be read in relation to everything else already there. A zero line cross that coincides with a key moving average, a major support/resistance level, or a volume profile node reads very differently from one occurring in open space. That kind of confluence is invisible when the oscillator is isolated in its own pane — it becomes immediately visible here.

This makes the indicator particularly useful for traders who are evaluating an oscillator-based approach before committing to it — or for those trying to understand why a seemingly clean oscillator system has underperformed in practice.

This indicator is published for educational and analytical purposes. It does not generate trade signals on its own — it relies entirely on the connected oscillator — and does not constitute financial advice. The overlay encodes a specific modeling choice, not a mathematical inversion of the oscillator. Validate behavior on your specific oscillator and instrument before drawing conclusions.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.