SMA Distance Bands & Dots
How far the price is from its long-term average, measured against how far it usually strays: statistically stretched highs and lows.
Two indicators and a screener share one calculation. SMA Distance Bands draws the distance from the 252-day average in its own pane, framed by ±σ bands of that same distance. SMA Distance Dots puts the extremes straight onto the price chart as dots. The SMA Distance Screener finds stretched names across a watchlist.
SMA Distance Bands
What it shows
| Element | Meaning |
|---|---|
| Distance line | Distance from the SMA in percent. Green above the average, red below. Muted inside the bands, full colour outside them — the extremes are what stands out. |
| Upper and lower bands | ±Sigma × the standard deviation of the distance. Named at the right edge with their values, e.g. +2σ 38.5%. |
| Grey fill | The normal range between the bands. |
| Zero line | The price is exactly at its average. |
| Background tint | Green while the line is above the upper band, red while it is below the lower band. |
How to read it
- • Above the upper band: the price is statistically stretched to the upside compared with its own history.
- • Below the lower band: stretched to the downside.
- • Back inside the band: the extreme is easing. A re-entry after an extreme is usually the more useful moment than the extreme itself: it often marks the end of the stretch.
- • Crosses of zero: the price moves from one side of its long-term average to the other.
Settings
Length of the simple moving average the distance is measured from; 252 trading days is one year.
Look-back of the standard deviation of the distance, about two years of daily bars. Shorter on a younger listing: the bars available, from 60.
Band width in standard deviations.
Calculates everything on daily data whatever the chart timeframe, so weekly and intraday charts show the daily model. Off: calculated on the chart timeframe.
Background tint while the line is outside the bands.
Alert conditions are confirmed at the bar close.
| Fixed value | Fixed at |
|---|---|
| Line inside the bands | line colour at 60% transparency |
| Line outside the bands | full colour |
| Line names | distance and both bands with their current values, at the right edge |
Alerts
Open Create alert → Condition: [Finaspex] SMA Distance Bands and pick a condition.
| Alert | Fires when |
|---|---|
| Above Upper Band | the distance is above the upper band |
| Below Lower Band | the distance is below the lower band |
| Cross Above Zero | the distance crosses above zero |
| Cross Below Zero | the distance crosses below zero |
| Re-entry From Above | the distance moves back inside the bands from above |
| Re-entry From Below | the distance moves back inside the bands from below |
SMA Distance Dots
What it shows
The same calculation as SMA Distance Bands, shown directly on the price chart with no pane and no lines. A green dot marks a bar whose distance is above the upper band (a stretched peak), a red dot a bar below the lower band (a stretched trough). Runs of dots show how long an extreme lasted; the first bar without a dot after a run is the re-entry.
Settings
SMA the distance is measured from.
Look-back for the standard deviation of the distance.
A dot prints when the distance is beyond ±Sigma · σ.
SMA and σ are calculated on daily data whatever the chart timeframe.
Dots and alerts appear on confirmed bars, so a dot never disappears once printed.
Master switch for the dots.
Shifts the dots left (−) or right (+) by N bars.
Peak: price far above the SMA.
Trough: price far below the SMA.
100 = solid, 0 = invisible.
Above/Below bar: green over the high, red under the low. Below/Above bar: the reverse. At close: both dots sit on the closing price.
Tiny, Small, Normal, Large or Huge.
Why the Style tab entries are locked: TradingView needs a fixed size and position for every dot series, so the script holds one internal copy per colour, placement and size and switches between them. Set colour, size and placement in the Inputs tab.
Why the default StDev Length differs from the bands (365 against 504): the dots are tuned to mark the clearest extremes on the price chart. To make the dots land exactly where SMA Distance Bands leaves its band, give both indicators the same SMA Length, StDev Length and Sigma.
Alerts
| Alert | Fires when |
|---|---|
| Green dot (peak) | the distance closes above the upper band |
| Red dot (trough) | the distance closes below the lower band |
| Back inside from above | the distance crosses back down into the band |
| Back inside from below | the distance crosses back up into the band |
SMA Distance Screener
Companion of the SMA Distance Bands indicator. The screener finds the candidates across a watchlist; open each match with the indicator to see the full picture.
[Finaspex] SMA Distance Screener runs the same distance-and-band calculation in TradingView’s Pine Screener and returns Match = 1 for symbols stretched below their long-term average or just recovering from that state.
- Add the screener to your Favorites in the Pine Editor (the Pine Screener lists favourite indicators).
- Open the Pine Screener, choose a watchlist (for example the S&P 500) and select the script.
- Set the period to 1D.
- Add the filter Match = 1 and click Scan. Sort Sigma Distance ascending to see the most stretched names first.
- Run it after the close, or turn on Evaluate Last Closed Bar when scanning during the session.
Match conditions
| Condition | True when |
|---|---|
| Below Lower Band | distance < lower band |
| Re-entry From Below | the distance crossed up through the lower band within the last Re-entry Lookback bars |
Settings
Up to 450, so the calculation fits the screener’s 500-bar window.
Shortened automatically so SMA + StDev fit inside the 500 bars.
Band width in standard deviations.
Include stocks currently below the lower band.
Include stocks that just crossed back above the lower band.
1 = a cross on the current bar; 3–5 if you scan occasionally.
Ignores the still-forming bar and uses the previous completed one.
Columns
| Column | Meaning |
|---|---|
| Match | 1 = signal, 0 = none |
| Distance % | Current distance from the SMA |
| Lower Band / Upper Band | Current band levels in % |
| Sigma Distance | Distance in standard deviations, e.g. −2.4 |
| Below Lower | 1 if the first condition is true |
| Re-entry From Below | 1 if the second condition is true |
| StDev Used | The standard-deviation window actually applied |
Why the screener uses a one-year σ window: the Pine Screener calculates the last 500 bars, and the SMA (252) plus the standard deviation must fit inside them. The window is set to fit automatically: StDev used = max(10, min(StDev Length, 495 − SMA Length − Re-entry Lookback)). The distance itself is identical to the chart indicator; the bands follow the last year instead of two. Deeply stretched names match on both; near −2σ the two can differ. To pre-filter, scan with Sigma 1.7–1.8 and confirm each candidate on the chart; for an exact match, set the chart indicator’s StDev Length to the value in StDev Used.
The Pine Screener does not send alerts. Use it to find the candidates, then set the alert on the SMA Distance Bands indicator on a chart, one symbol at a time.
Methodology
upper band = +Sigma × σ lower band = −Sigma × σ
With Use Daily Calculation On All Timeframes on, the distance and σ are requested from daily data, so weekly and intraday charts show the daily model. With it off, they are calculated on the chart’s own bars.
Why the distance is divided by the close: it expresses the gap as a share of today’s price, which keeps the upside readable — even a parabolic rally stays below +100%. The figure therefore differs slightly from “percent above the average” (close ÷ SMA − 1) quoted elsewhere; the bands are built from the same series, so the comparison between line and bands is exact.
Why the bands are centred on zero: zero is the average itself, so the bands answer “how far from the average is unusual for this stock?”. A stock in a long uptrend spends most of its time above zero and reaches the upper band more often than the lower one — which is part of the reading.
Scope and design choices
+2σ 45.3% · 320 bars.Works well with
For dividend stocks: is a stock stretched below its average also cheap by its own yield history?
Trend Leaders →Whether a stretched stock is a market leader, and where its base, pivot and stop are.
Sigma Cone →The forward view of the same idea: how far the price can statistically travel from here.