Explainers / Pivot Point SuperTrend
Pivot Point SuperTrend, explained from the source
"Pivot Point SuperTrend" by LonesomeTheBlue is one of the most-boosted free trend scripts on TradingView, with more than 29,000 boosts. It looks like a SuperTrend, but the middle of its bands is not price. It is a running average of recent swing highs and lows, with ATR bands drawn around that average and a trailing line that follows whichever band is on the trend side.
How it works
- Find pivots. A pivot high is a bar whose high is above the highs of the bars on each side; a pivot low is the mirror. The "Pivot Point Period" (default 2) is how many bars on each side. A pivot is only confirmed that many bars after it happened, and the script uses it from that bar on.
- Average them into a centre line. The first pivot sets the centre. Each later pivot, high or low, updates it as two thirds of the old centre plus one third of the new pivot. Recent pivots count most; older ones fade but never fully leave.
- Draw ATR bands around the centre. Upper and lower bands sit "ATR Factor" times ATR (defaults 3 and 10) above and below the centre line, not above and below price.
- Trail. In an uptrend the lower band only moves up while the previous close is above it. In a downtrend the upper band only moves down while the previous close is below it. A close beyond the opposite band flips the trend and the line switches sides.
- Label the flip. The script prints a label it calls "Buy" when the trend turns up and "Sell" when it turns down, at the line value. Its alerts use the same two conditions plus "Trend Changed".
Why it is not a normal SuperTrend
A normal SuperTrend hangs its bands off the current price (usually the bar's midpoint). Here they hang off a slow average of swing points. That has two visible effects. The line can sit a long way from price: on our random-walk test the median gap between close and line was 3.6 ATR and one bar in ten was over 6.1 ATR. And the line moves only when a new pivot is confirmed or ATR changes, so in a fast move it can stay put while price runs.
Timing: what is known when
Pivots arrive late by design: at the default of 2, a swing high is confirmed 2 bars after it printed, and the centre line updates then, not on the swing bar. The line and flips use confirmed pivots and the bar's close, so history does not rewrite itself the way a pivot label drawn back in time does. Two things to watch:
- Live bar. The trend test uses the close, which on an open bar is the current price. A flip label can appear and disappear before the bar closes, and an alert set to fire on every tick follows it. Use "once per bar close" if you want it to match the closed chart.
- Hindsight displays. "Show Pivot Points" and "Show Support/Resistance" are drawn two bars back, on the pivot bar, even though the script only knew about it two bars later. A finished chart makes those marks look earlier than they were.
The settings
| Setting | Default | What it does |
|---|---|---|
| Pivot Point Period | 2 | bars each side for a pivot; also the confirmation delay. At 2, about one bar in four becomes a confirmed pivot on random prices |
| ATR Factor | 3 | band distance in ATRs. Biggest lever: on random prices a flip came every ~21 bars at 1, ~58 at 3 and ~100 at 5 |
| ATR Period | 10 | smoothing of the ATR that sets band width |
| Show Pivot Points | off | marks each pivot, drawn 2 bars back |
| Show Buy/Sell Labels | on | the flip labels |
| Show PP Center Line | off | the average itself, blue when below the bar's midpoint, red when above |
| Show Support/Resistance | off | the latest pivot low and high as dots, drawn 2 bars back |
Raising the pivot period makes the centre line slower, not smarter: on the same random data, 5 gave a flip about every 72 bars and 10 about every 90.
The alerts
Three alert conditions: "Buy Signal", "Sell Signal" and "Trend Changed". The names are the script's; they test only whether the trend flag changed. Nothing in the code checks what price does afterwards, and the page does not either.
Where it fails
- Flips on noise. On random prices with no structure at all, the defaults still flipped about every 58 bars, so a flip alone says nothing about trend.
- Line far from price. Because the bands hang off an average of old pivots, the line can sit several ATR from the close; any exit or stop idea built on it inherits that gap.
- Slow in fast markets. The centre moves only when a pivot is confirmed, so it lags sharp moves by design.
- Live-bar flicker. The test uses the close, so flips on an open bar can reverse before the close.
- Hindsight marks. Pivot and support/resistance displays are drawn two bars back.
- One setting set for everything. The same defaults apply to every market and timeframe; nothing tests whether a given setting suits one.
- Version 4 code. Written in Pine v4 (2020); it runs but is not the current language.
Also explained: Supertrend · Chandelier Exit · UT Bot Alerts · Pivot Points High Low · Repainting
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Pivot Point SuperTrend is by LonesomeTheBlue on TradingView, published under the Mozilla Public License 2.0; this page explains its published open-source code and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the indicator trades.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue
No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.