OPEN-SOURCE SCRIPT
Relative Positioning Map

█ OVERVIEW
A cross-sectional relative-positioning map. It shows where each of up to 20 instruments sits versus a configurable benchmark right now, measured in daily-volatility units of the relative spread and anchored to the current session's open. It is a visualization and decision-support tool for relative momentum, cross-sectional dispersion and mean-reversion attention on a basket that shares one reference — for example semiconductor names against an ETF, or any sector against a broad index.
The benchmark is fully configurable, so the same tool works on any universe you want to read against a common index. Because every spread is referenced to the same benchmark and scaled the same way, the curves are directly comparable to one another.
█ WHAT IT IS, AND WHAT IT IS NOT
It is a relative-momentum and dispersion map, plus optional intraday attention shading. It is not a buy/sell signal generator and not a mean-reversion entry system: the shaded windows are attention zones, and any alert it raises flags a large relative move, not a trade.
█ WHAT MAKES IT DIFFERENT
Many relative-strength plots normalise a windowed return, such as price now divided by price a fixed number of bars ago. That quantity decays on its own as the lookback rolls past an old move, so the line can fall back toward zero even when price has not reverted at all — the plot and the price disagree. This script avoids that by working on the level of the relative spread rather than on a windowed return, and by anchoring to a static session reference that never chases the level the way a moving average would.
█ CONCEPTS
For each instrument versus the benchmark:
• Relative spread, as a level. s = log( price of instrument / price of benchmark ). It is pulled as a single synthetic ratio series built from the bare tickers. A single series is required because the volatility of a difference carries the cross-covariance of the two legs, which only exists when the ratio is one series. All calculations run at the chosen resolution, which makes the map independent of the chart's own timeframe.
• Session anchor. The opening value of the spread is captured at the session open and held fixed for the whole day, resetting each morning. It is static, not a moving average, so it never chases the level.
• Positioning value. v = ( spread now minus the opening spread ) divided by the spread's daily volatility. A reading of +2 means the instrument is two daily spread standard deviations above where it opened versus the benchmark; a reading of -5 means it has been five below and stayed there. Persistence is information, not an error: a chronically weak name can legitimately sit near -5 all day. No reversion is implied.
• Cross-sectional dispersion bands. At every bar the mean and standard deviation of the values across the whole basket are drawn as envelopes. Wide bands mean high dispersion (names diverging — the classic dispersion-trading backdrop); narrow bands mean the group is moving together.
• Benchmark baseline. The benchmark is the zero line by definition. It is drawn as a band tinted by its own short-term trend, so the regime the whole basket is riding is always visible.
█ HOW TO USE
1 — Set the Benchmark: the denominator of every spread. Change it to a broad index, a sector ETF, or any instrument. Prefer a bare ticker so the synthetic ratio resolves cleanly.
2 — Fill the Universe slots with up to 20 instruments; leave a slot empty to skip it.
3 — Pick the Resolution: the analysis timeframe that drives the calculations, independent of the chart timeframe.
4 — Read the curves: the top of the pane holds the relative outperformers, the bottom the laggards, scaled in daily spread standard deviations since the open.
5 — Read the dispersion bands for the regime: widening envelopes mean a dispersing basket (the dispersion-trading backdrop); contracting envelopes mean convergence.
6 — Use the grey mean-reversion attention windows as reminders of the times of day you choose to watch for reversion in the spreads. They are visual only; validate any reversion with your own analysis.
7 — Use the mover labels and the ranking table to see which names became extreme or accelerated away from the index, and the daily volatility of each spread for sizing.
█ FEATURES
• Configurable benchmark and up to 20 instruments, all comparable on one scale.
• Chart-timeframe-independent computation through a synthetic ratio evaluated at a chosen resolution.
• Cross-sectional dispersion envelopes around the basket mean.
• A trend-tinted benchmark baseline.
• Two configurable intraday attention windows (mean-reversion zones) plus further session highlights, with timezone and transparency controls.
• Mover labels that trigger on extreme positioning OR on acceleration away from zero, with a confirmation requirement, a per-name re-label cooldown, an end-of-session suppression window, and automatic anti-overlap stacking. Historical mover labels are semi-transparent; the live right-margin labels showing the current state are solid.
• A ranking table with each name's positioning value and its spread's daily volatility.
█ LIMITATIONS
• Relative spreads are not guaranteed to mean-revert. Whether a given pair reverts on your timeframe is an empirical question of stationarity and half-life that this tool does not test for you. Treat the shaded windows as attention zones only.
• In extended hours the synthetic ratio depends on both legs trading; where one leg is illiquid you will see stepwise or flat segments. That is market microstructure, not a calculation error.
• The synthetic ratio is built from bare tickers; an unusual symbol that does not resolve will show no data on that slot.
• Higher-timeframe values are requested without lookahead, so historical values are fixed once a bar of the chosen resolution closes; only the currently forming bar updates in real time. This is expected behaviour.
█ NOTES
This script is a context and visualization tool. It does not place orders, and its alerts are informational rather than trade instructions. Nothing in it constitutes financial advice, and past behaviour visible on the chart does not guarantee future results.
═════════════════════════════════════════════════════════════════════════
Published open-source so the calculations can be inspected and adapted. Reuse is governed by the license shown with the source and by TradingView's House Rules.
A cross-sectional relative-positioning map. It shows where each of up to 20 instruments sits versus a configurable benchmark right now, measured in daily-volatility units of the relative spread and anchored to the current session's open. It is a visualization and decision-support tool for relative momentum, cross-sectional dispersion and mean-reversion attention on a basket that shares one reference — for example semiconductor names against an ETF, or any sector against a broad index.
The benchmark is fully configurable, so the same tool works on any universe you want to read against a common index. Because every spread is referenced to the same benchmark and scaled the same way, the curves are directly comparable to one another.
█ WHAT IT IS, AND WHAT IT IS NOT
It is a relative-momentum and dispersion map, plus optional intraday attention shading. It is not a buy/sell signal generator and not a mean-reversion entry system: the shaded windows are attention zones, and any alert it raises flags a large relative move, not a trade.
█ WHAT MAKES IT DIFFERENT
Many relative-strength plots normalise a windowed return, such as price now divided by price a fixed number of bars ago. That quantity decays on its own as the lookback rolls past an old move, so the line can fall back toward zero even when price has not reverted at all — the plot and the price disagree. This script avoids that by working on the level of the relative spread rather than on a windowed return, and by anchoring to a static session reference that never chases the level the way a moving average would.
█ CONCEPTS
For each instrument versus the benchmark:
• Relative spread, as a level. s = log( price of instrument / price of benchmark ). It is pulled as a single synthetic ratio series built from the bare tickers. A single series is required because the volatility of a difference carries the cross-covariance of the two legs, which only exists when the ratio is one series. All calculations run at the chosen resolution, which makes the map independent of the chart's own timeframe.
• Session anchor. The opening value of the spread is captured at the session open and held fixed for the whole day, resetting each morning. It is static, not a moving average, so it never chases the level.
• Positioning value. v = ( spread now minus the opening spread ) divided by the spread's daily volatility. A reading of +2 means the instrument is two daily spread standard deviations above where it opened versus the benchmark; a reading of -5 means it has been five below and stayed there. Persistence is information, not an error: a chronically weak name can legitimately sit near -5 all day. No reversion is implied.
• Cross-sectional dispersion bands. At every bar the mean and standard deviation of the values across the whole basket are drawn as envelopes. Wide bands mean high dispersion (names diverging — the classic dispersion-trading backdrop); narrow bands mean the group is moving together.
• Benchmark baseline. The benchmark is the zero line by definition. It is drawn as a band tinted by its own short-term trend, so the regime the whole basket is riding is always visible.
█ HOW TO USE
1 — Set the Benchmark: the denominator of every spread. Change it to a broad index, a sector ETF, or any instrument. Prefer a bare ticker so the synthetic ratio resolves cleanly.
2 — Fill the Universe slots with up to 20 instruments; leave a slot empty to skip it.
3 — Pick the Resolution: the analysis timeframe that drives the calculations, independent of the chart timeframe.
4 — Read the curves: the top of the pane holds the relative outperformers, the bottom the laggards, scaled in daily spread standard deviations since the open.
5 — Read the dispersion bands for the regime: widening envelopes mean a dispersing basket (the dispersion-trading backdrop); contracting envelopes mean convergence.
6 — Use the grey mean-reversion attention windows as reminders of the times of day you choose to watch for reversion in the spreads. They are visual only; validate any reversion with your own analysis.
7 — Use the mover labels and the ranking table to see which names became extreme or accelerated away from the index, and the daily volatility of each spread for sizing.
█ FEATURES
• Configurable benchmark and up to 20 instruments, all comparable on one scale.
• Chart-timeframe-independent computation through a synthetic ratio evaluated at a chosen resolution.
• Cross-sectional dispersion envelopes around the basket mean.
• A trend-tinted benchmark baseline.
• Two configurable intraday attention windows (mean-reversion zones) plus further session highlights, with timezone and transparency controls.
• Mover labels that trigger on extreme positioning OR on acceleration away from zero, with a confirmation requirement, a per-name re-label cooldown, an end-of-session suppression window, and automatic anti-overlap stacking. Historical mover labels are semi-transparent; the live right-margin labels showing the current state are solid.
• A ranking table with each name's positioning value and its spread's daily volatility.
█ LIMITATIONS
• Relative spreads are not guaranteed to mean-revert. Whether a given pair reverts on your timeframe is an empirical question of stationarity and half-life that this tool does not test for you. Treat the shaded windows as attention zones only.
• In extended hours the synthetic ratio depends on both legs trading; where one leg is illiquid you will see stepwise or flat segments. That is market microstructure, not a calculation error.
• The synthetic ratio is built from bare tickers; an unusual symbol that does not resolve will show no data on that slot.
• Higher-timeframe values are requested without lookahead, so historical values are fixed once a bar of the chosen resolution closes; only the currently forming bar updates in real time. This is expected behaviour.
█ NOTES
This script is a context and visualization tool. It does not place orders, and its alerts are informational rather than trade instructions. Nothing in it constitutes financial advice, and past behaviour visible on the chart does not guarantee future results.
═════════════════════════════════════════════════════════════════════════
Published open-source so the calculations can be inspected and adapted. Reuse is governed by the license shown with the source and by TradingView's House Rules.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.