Explainers / Pivot highs and lows
Pivot Points High Low & Missed Reversal Levels by LuxAlgo, explained from the source
The most-boosted pivot script on TradingView is LuxAlgo's "Pivot Points High Low & Missed Reversal Levels". It marks swing highs and lows on the chart, joins them with a zigzag, and adds ghost markers for turning points it calls "missed". On a finished chart it looks like it caught every top and bottom. This page explains, from the published source, why it looks that way. The short version: a pivot can only be known a fixed number of bars after it happens, and the marker is then drawn back at the bar where it happened.
What a pivot high is
A pivot high is a bar whose high is higher than the highs of a set number of bars on each side. Pine Script has this built in: ta.pivothigh(left, right). A pivot low is the mirror, using lows.
The LuxAlgo script uses the same number on both sides: Pivot Length, 50 by default. So a bar is a pivot high when its high beats the 50 bars before it and is not beaten by the 50 bars after it.
Why it appears N bars late
Read that definition again: "the 50 bars after it". Nobody knows whether a high is a pivot until those 50 bars have closed. So ta.pivothigh(50, 50) returns nothing on the bar of the high, and returns the high's price 50 bars later.
The script then places the marker at the bar of the high, 50 bars back (bar_index - length in the code). On a historical chart you see a label sitting exactly on the top. Live, that label did not exist until 50 bars after the top.
This is not a bug, and the label does not move once drawn. It is the definition of a pivot. But it means the chart shows you the pivots with hindsight. With a length of 50 on a daily chart, each marker appeared about ten weeks after the date it sits on. See what repainting is for why back-dated drawings look better than they traded, or test a script with the repaint checker.
What the "missed reversal levels" are
A clean zigzag goes high, low, high, low. Sometimes two pivot highs arrive with no pivot low between them: price dipped between them, but not far enough or long enough to pass the 50-bar test.
The script keeps track of the lowest low since the last pivot. When a second pivot high arrives in a row, it puts a ghost marker on that lowest low and draws a dashed zigzag segment to it, so the zigzag still alternates. The mirror happens for two pivot lows in a row.
There is a second case. Pivots can alternate correctly and still skip a swing: if a new pivot high is lower than the highest high since the last pivot, the script puts a ghost on that higher high and another ghost on the lowest low that followed it, then joins them with dashed segments. The mirror happens for pivot lows.
So a ghost marker is a turning point that failed the pivot test and was filled in afterwards, at the moment the next pivot was confirmed. It is drawn even later than a regular pivot.
Each ghost also starts a thick, faded horizontal level. The newest one is stretched to the current bar on every bar until the next ghost replaces it.
The one marker that moves
Everything above is drawn once and stays put. The exception is on the last bar. There the script looks back to the last confirmed pivot, finds the most extreme price since then (the lowest low after a pivot high, or the highest high after a pivot low), and puts a ghost on it with a level running to the current bar. It deletes and redraws that ghost on every new bar. So while a swing is still unconfirmed, the newest ghost slides to each new extreme. Watch it live and you will see it jump; on a historical chart only its final position is left.
How often pivots happen
In a simulation on pure random-walk prices (200,000 bars, nothing to predict):
- With a length of 50, a pivot high appeared about every 157 bars and a pivot low about every 155. With a length of 5, about every 16 bars. Pivots come about every three lengths on noise, so a pivot by itself is not a sign of anything.
- About one pivot in seven came right after a pivot of the same type. Those are the gaps the ghost markers fill, so ghosts are a normal part of the picture, not a rare event.
- The delay was always exactly the length, because that is how a pivot is defined.
Settings, honestly
- Pivot Length (50): the only real setting. Larger means fewer, bigger swings and a longer delay. Smaller means more pivots, most of them noise, and a shorter delay. There is no setting that gives big swings without a big delay.
- Regular Pivots / Missed Pivots: show or hide each kind. Colours are cosmetic.
Where it fails
- Hindsight. Every marker is placed back in time after a delay of Pivot Length bars. A historical chart full of perfect tops and bottoms is what the definition produces, not evidence of anything.
- Ghosts are later still. A missed level is only drawn when the next same-type pivot confirms, which can be long after the low or high it marks.
- The newest ghost moves. On the live bar the latest ghost is redrawn at each new extreme until the next pivot confirms. It is a running high or low, not a turning point.
- Noise. On random data a pivot appears about every three lengths. Most pivots are ordinary wiggles.
- No forecast. A pivot high says that a high was the highest point in a window around it. It does not say price will return to it or respect it.
Also explained
Educational content only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Original script by LuxAlgo on TradingView (CC BY-NC-SA 4.0); this page explains its published source and quotes no code beyond the names of Pine built-ins.
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, 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, Pivot Point SuperTrend, 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
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy
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.