OPEN-SOURCE SCRIPT
Updated

SwiftLevels

1 313
SwiftLevels is a clean, all-in-one overlay indicator that keeps the most important price reference levels and daily moving averages visible at a glance — without cluttering your chart.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PRIOR DAY & PRIOR WEEK LEVELS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
On intraday charts, SwiftLevels draws horizontal lines for the prior day high/low and prior week high/low. Lines are anchored to the prior session's open so they don't clutter the left side of the chart. Labels float at the right edge of the current session and update each bar close to show the live percentage distance from price — positive when price is above, negative when below.

Example: PRIOR DAY (+1.24%) PRIOR WEEK (-0.87%)

Colors and label visibility are fully configurable per level group.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DAILY MOVING AVERAGES (5 fully configurable)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Five independent moving averages, each calculated from daily chart data regardless of your current timeframe.

On intraday charts:
• Each MA is drawn as a clean horizontal line starting at today's session open and extending right — no stair-stepping history, no noise from previous sessions.
• Labels appear just before the line starts, showing the MA name and live % distance from price, updated each bar close.
• Example: 20d SMA (+2.11%) 50d SMA (-0.44%)

On the daily chart:
• MAs are displayed as traditional full-history plots so you can see the curve over time.
• Can be toggled on/off with the "Display on Daily" checkbox.

On weekly/monthly charts:
• MAs are hidden to keep those timeframes uncluttered.

Each moving average is independently configurable:
• Enable / disable
• Length (default: 5, 10, 20, 50, 200)
• SMA or EMA toggle
• Custom color
• Line width
Release Notes

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: DAILY MOVING AVERAGES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Added 5 fully configurable daily moving averages. Each MA is calculated from daily chart data and displayed as a clean horizontal line on intraday charts — starting at today's session open with no historical stair-stepping. On the daily chart they render as traditional full-history plots. Hidden on weekly/monthly to keep those views clean.

Each MA is independently configurable: enable/disable, length, SMA or EMA, color, and line width. Defaults are 5, 10, 20, 50, and 200 period.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: STATUS DATA BOX
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A compact table in the top-right corner shows where price stands relative to every level and moving average, updated on each bar close.

🟢 above 🔴 below 🟡 proximity alert

For level rows (Prior Day / Prior Week), yellow indicates price is currently trading inside the prior week range. For MA rows, yellow triggers when price is within ±0.20% of the MA — signalling a near-touch or active test of that average. Each row also shows the live percentage distance, color-coded to match.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPROVED: LABELS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All labels now include a live percentage distance from the current price, updated on bar close. Labels for Prior Day and Prior Week levels float at the right edge of the session. MA labels are anchored just before the line starts on the left side. Label text updated to "PRIOR DAY" and "PRIOR WEEK" for clarity.
Release Notes
SwiftLevels — Version 2.1 Changes

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPROVED: DATA BOX — LEVEL ROWS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Prior Day and Prior Week are now each a single combined row instead of separate high/low rows. The status dot reflects the full range:

🟢 price is above the range high
🔴 price is below the range low
🟡 price is inside the range

When price is inside the range, the percentage column now shows "Inside" instead of a dash, so it's immediately clear what the yellow dot means without hovering.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: DATA BOX — SLOPE COLUMN
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A fourth column has been added to the data box showing the daily slope direction for each moving average:

▲ green — MA is trending higher today vs. yesterday
▼ red — MA is trending lower today vs. yesterday

Slope is calculated by comparing today's daily MA value against yesterday's confirmed daily close — so the direction reflects actual daily momentum, not intraday noise.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: DATA BOX — HOVER TOOLTIPS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Hovering over cells in the data box now shows context-sensitive detail:

Status dot — plain-English description of price position relative to the level
(e.g. "Price is above the Prior Day range (+1.24% above the high)")
Label cell — shows the actual price values for the level or MA
(e.g. "Prior Day · High: 5,412.00 Low: 5,387.50")
Slope arrow — confirms direction
(e.g. "20d SMA is sloping up")

Tooltips are fully dynamic and update with each bar close.
Release Notes
SwiftLevels — Version 2.2 Changes

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: PRIOR DAY -2 & PRIOR WEEK -2 LEVELS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A second tier of reference levels has been added: the high/low from two days back (Prior Day -2) and two weeks back (Prior Week -2). These draw as dashed lines in a dimmer shade of the existing level colors, so they're clearly secondary to the primary prior-day/prior-week lines. Each has its own input group (color, line width, label toggle) and floating labels with live percentage distance, exactly like the originals.

These appear as lines only — they are not added to the data box.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: DATA BOX SECTIONS & HEADERS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The data box is now split into two labelled sections with header strips:

POSITION — Prior Day, Prior Week, and the 5 moving averages
PERFORMANCE — period gains (see below)

Each section can be shown or hidden independently from the new "Data Box" settings group. Hiding POSITION slides PERFORMANCE up to the top; hiding both removes the data box entirely.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEW: PERFORMANCE GAINS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
A new PERFORMANCE section shows how far price has moved over five horizons, each measured against the prior completed period's close:

Day Gain — vs prior daily close
Week Gain — vs prior weekly close
Month Gain — vs prior monthly close
YTD Gain — vs prior-year close
1-Year Gain — vs the close ~252 trading days ago

Each row has a 🟢/🔴 dot, a sign-colored percentage, and a hover tooltip showing the reference price.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPROVED: PERFORMANCE (UNDER THE HOOD)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All higher-timeframe data requests were consolidated from 23 separate security calls down to 5 by bundling same-timeframe values into single tuple requests. Security calls are the dominant cost in Pine, so the indicator now loads and runs noticeably lighter with no change to behavior.

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.