Explainers / Liquidity Swings [LuxAlgo]
Liquidity Swings [LuxAlgo], explained from the source
Liquidity Swings is an open-source TradingView script by LuxAlgo (about 42,000 boosts). It marks the latest swing high and swing low with a line and a shaded zone, and prints a number next to each. This page walks through what the published code does, what each setting changes, and where it fails. It does not say what price does at a zone.
The surprise: the number on the label is volume, and the width of the zone is a bar count
The setting called "Filter Areas By" offers Count or Volume, which suggests the label shows whichever you chose. It does not. The label text is always the summed volume, written in short form. The count only decides two things: whether a level is drawn at all, and how wide the zone is. The zone is drawn from the swing bar to a point that many bars to the right, so its width equals the count of bars, not the time between the first and last touch. A zone four bars wide does not mean four touches happened in four bars.
Step 1: the swings are single pivots, known 14 bars late
A swing high is a bar whose high is the highest among the 14 bars on each side (Pivot Lookback, 14 by default; one setting for both sides). A pivot needs 14 bars to its right before it exists, so each swing is only known 14 bars after the bar it sits on. The script then draws it back at the pivot bar. The same applies to swing lows.
Step 2: what the zone is made of
For a swing high the zone runs from the pivot bar's high down to the top of its candle body (the higher of open and close). That is the upper wick. With "Full Range" it runs down to the pivot bar's low, so the zone covers the whole candle. A swing low mirrors this. The line is drawn at the high of a swing high and the low of a swing low.
Step 3: what gets counted
After a new pivot, the script starts counting. On every bar it looks at the bar from 14 bars ago and asks one question: did that bar's range overlap the zone, meaning its low is below the zone top and its high is above the zone bottom. If yes, the count goes up by one and that bar's whole volume is added to the total. So:
- A bar that only brushes the edge counts the same as a bar that sits in the zone all day, and adds its entire volume, including volume traded far from the zone.
- A bar that passes straight through the zone counts. The count is "bars that overlapped", not "times price turned around here".
- Because it reads the bar 14 back, the count always trails the live chart by 14 bars.
Step 4: the count keeps growing after the level breaks
A level counts as crossed when a bar closes beyond it (above a swing high, below a swing low). At that point the line stops, turns dashed, and the shaded area collapses. The count and the volume total do not stop. They keep adding bars that overlap the zone until the next pivot on that side replaces the level. In the synthetic test below, 44 percent of levels were crossed before they were replaced, and for those, about 30 percent of the final count came from bars after the bar that crossed. So a large number on a label does not tell you the level held.
Step 5: only one level per side is live
Each new pivot starts a fresh count and the previous level stops where the new one begins. The old line and label stay on the chart as history. If you set the filter above zero, a level whose count is below the filter is deleted when the next pivot arrives, so low-count levels disappear from the chart afterwards. The lines have no colour until the count passes the filter, and that check does not look at whether the level is already crossed, so with a filter above zero a level can turn visible after it has already been broken.
Step 6: Intrabar Precision
When ticked, the volume part (not the count) is recomputed from one-minute bars (or the timeframe you pick): only the minute bars whose own range overlaps the zone add their volume. This gives a tighter volume number than adding the whole chart bar. It depends on TradingView having that many lower-timeframe bars loaded, which limits how far back it works. The script requests the lower-timeframe data on every chart whether or not the box is ticked.
What the settings change (synthetic prices, seeds 1 to 3)
On random prices with no structure, swing levels replaced each other about every 46 bars at the default length. With the default Wick Extremity zone the count averaged 3.8 (median 2). Switching to Full Range, which makes the zone taller, raised it to 9.7 (median 8) on the same prices. The count is mostly a measure of how tall the zone is. These are counts on invented data: they show how the code behaves, not whether a number means anything.
Where it fails
- Late by design. Each swing is known 14 bars after the bar it sits on, so every zone refers to a turn that has already happened.
- The label is volume, whatever you filter by. Choosing Count changes which levels show, not what the number says.
- Whole-bar volume. Without Intrabar Precision, a bar that touches the zone with one tick adds all of its volume.
- Pass-through counts like a touch. A bar that runs through a zone is counted the same as one that stops there.
- Counts continue after a break. The number keeps growing for a level that has already been closed through.
- Zone height drives the count. A taller zone catches more bars, so counts compare badly between settings and between instruments.
- One level per side. A new pivot replaces the live level, so the count never reflects more than one swing.
- Needs volume data. On symbols without volume the volume text is zero and a Volume filter hides everything.
- Intrabar limits. Lower-timeframe history is capped by TradingView, so Intrabar Precision stops covering older bars.
- No alerts. The script has no alert conditions, so there is nothing to automate from it.
Also explained: Support and Resistance Levels with Breaks · Trendlines with Breaks · Pivot Points High Low · Order Block Finder · Market Structure Break & Order Block
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Liquidity Swings [LuxAlgo] is by LuxAlgo on TradingView, published under CC BY-NC-SA 4.0; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script 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, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, 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.