OPEN-SOURCE SCRIPT
Updated 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 PulseWire'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 PulseWire's House Rules.
Release Notes
WHAT'S NEWRelative strength calculation
The score is no longer demeaned: it is the volatility-adjusted differential versus the benchmark, divided by its own rolling standard deviation. The sign of each curve now reads directly as "currently ahead of / behind the benchmark", which is consistent with the index identity — if the benchmark is up, some of its components must be ahead of it. Structurally leading or lagging names are no longer recentred on zero.
Benchmark as the baseline
The separate benchmark curve is gone, along with its data request. The benchmark is the zero line itself, drawn as an opaque foreground band coloured by its own trend: white when flat, deepening green when bullish, deepening red when bearish. The band is extended past the live bar into the right margin, with adjustable thickness and length, and the context box now rests on it.
Daily volatility
The volatility column is a realised-variance estimate: squared log returns are accumulated within each session, averaged over a rolling window of completed days, then square-rooted. This replaces the square-root-of-time rescaling of the intraday EWMA and stays comparable across analysis resolutions.
Pre-market opening range
New optional column flagging, per symbol, a breakout above or below its pre-market opening range. Window and timezone are configurable. It requires an intraday analysis resolution and forces extended-hours data on the universe.
Labels
Rotation labels now require both a minimum absolute score and a fractal confirmation over several consecutive closed bars, which removes the one-bar crossings near zero. The right-margin symbol labels are de-overlapped: slots are sorted and stacked with a configurable minimum vertical gap, while the text keeps the true value — only the box moves. Label size is now an input.
Bands and sessions
The cross-sectional mean and dispersion can be smoothed before plotting, turning the sigma bands into clean envelopes; set the smoothing to zero for the previous raw behaviour. Only the bands are affected, not the symbol curves. Time-of-day shading goes from one window to three independently configurable sessions, each with its own colour, in a selectable timezone.
Data and performance
The extended-hours toggle is applied consistently to the benchmark and to every slot. Each slot returns its score, its volatility and its opening-range state from a single external data request, keeping the script at 21 requests in total. The ranking table gained the volatility and breakout columns, and each symbol cell is painted with its curve colour. Defaults have been retuned for an intraday workflow; presets for daily and faster resolutions are in the description.
Unchanged
Data is still requested with lookahead disabled: values of closed bars are final and only the forming bar updates in real time. Rotation labels are placed on confirmed bars only.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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 PulseWire. Read more in the Terms of Use.
Open-source script
In true PulseWire spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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 PulseWire. Read more in the Terms of Use.
