OPEN-SOURCE SCRIPT
Liquidity Bands

1. CONCEPT & PURPOSE
Liquidity Bands is a volume-weighted volatility envelope indicator. Unlike standard Bollinger Bands that use a Simple Moving Average and equal-weighted standard deviation, this indicator weights every price observation by its liquidity (volume × true range). This means:
High-volume, high-volatility bars have a stronger influence on the bands
Low-volume, quiet bars contribute less to the calculation
The bands naturally gravitate toward price levels where real trading activity occurred
This makes the bands more responsive to institutional activity and genuine supply/demand zones rather than treating every bar equally.
2. CORE CALCULATIONS
2.1 Liquidity Proxy
text
liquidity = volume × true_range
Each bar's "weight" is determined by multiplying its volume by its true range. This captures dollar-flow intensity — a bar with high volume AND wide range represents significant market participation. If volume is unavailable (e.g., some crypto pairs), it defaults to 1 so the indicator still functions.
2.2 Liquidity-Weighted Moving Average (LMA)
text
LMA = Σ(price × liquidity, n) / Σ(liquidity, n)
Instead of a simple average where each bar counts equally, the LMA is a weighted mean where high-liquidity bars pull the average toward their price level more strongly. This is the center line (basis) of the bands.
Interpretation:
LMA represents the fair value based on where the most trading activity occurred
Price above LMA → bullish bias
Price below LMA → bearish bias
2.3 Liquidity-Weighted Standard Deviation
text
variance = Σ(price² × liquidity, n) / Σ(liquidity, n) − LMA²
std_dev = √variance
The standard deviation is also liquidity-weighted, meaning volatility is measured relative to where liquidity actually participated, not just raw price swings.
2.4 Band Construction
Band Formula Purpose
Upper Band LMA + (mult × std_dev) Overbought / resistance zone
Lower Band LMA − (mult × std_dev) Oversold / support zone
Inner Upper LMA + (inner_mult × std_dev) First standard deviation — early warning
Inner Lower LMA − (inner_mult × std_dev) First standard deviation — early warning
Default multipliers: Outer = 2.0, Inner = 1.0
This creates four zones:
Above upper band → extreme overbought
Upper band to inner upper → overbought zone
Inner upper to inner lower → neutral / fair value zone
Inner lower to lower band → oversold zone
Below lower band → extreme oversold
3. SIGNAL MODES
3.1 Mean Reversion Mode
Philosophy: Price tends to return to the mean after touching extremes.
Signal Condition Logic
LONG Previous close was at or below the lower band, current close is back above it Price was rejected at the lower extreme and is recovering — buy the bounce
SHORT Previous close was at or above the upper band, current close is back below it Price was rejected at the upper extreme and is fading — sell the rejection
Best used in: Ranging/sideways markets, mean-reverting instruments, when squeeze is active.
3.2 Breakout Mode
Philosophy: When price breaks through the bands with conviction, momentum follows.
Signal Condition Logic
LONG Price crosses above the upper band Bullish momentum breakout — buy the strength
SHORT Price crosses below the lower band Bearish momentum breakdown — sell the weakness
Best used in: Trending markets, after a squeeze, high-momentum instruments.
3.3 Both Mode
Fires signals from either mode. Useful for scanning all opportunities but requires additional context/filtering to avoid conflicting signals.
3.4 LMA Cross Signals (Optional)
Signal Condition
Cross Up Price crosses above the LMA basis line
Cross Down Price crosses below the LMA basis line
These are secondary/confirmation signals — a diamond shape appears. Useful for:
Confirming a mean reversion signal (price bounced off band AND crossed back above LMA)
Identifying trend direction shifts
4. BAND WIDTH & SQUEEZE DETECTION
4.1 Band Width
text
band_width = (upper_band − lower_band) / LMA × 100
Expressed as a percentage of the LMA, this normalizes volatility across different price levels and instruments. A 5% band width means the bands span 5% of the current price level.
4.2 Squeeze Detection
text
squeeze = band_width < lowest(band_width, 50) × 1.05
A squeeze is detected when the current band width is within 5% of the lowest band width in the last 50 bars. This means volatility has contracted to near-historic lows for the recent window.
What it means:
Energy is building — a large move is likely coming
Direction is unknown — wait for breakout confirmation
Displayed as a soft orange/yellow background tint across the chart
4.3 Expansion Detection
text
expansion = band_width > highest(band_width[1], 20) × 0.95
Bands are expanding when width is near the 20-bar high. This confirms an active trend/momentum move is underway.
4.4 Price Position Ratio
text
ratio = (close − lower_band) / (upper_band − lower_band)
Gives a 0–100% reading of where price sits within the bands:
0% = at the lower band
50% = at the LMA
100% = at the upper band
>100% = above upper band
<0% = below lower band
Displayed as a visual gauge bar ████░░░░░░ 40% in the dashboard.
5. VISUAL SYSTEM
5.1 Color Themes
Theme Character Upper Lower Best For
Cyber Futuristic neon Cyan #00e5ff Pink #ff006e Dark charts
Ocean Cool aquatic Teal #00b4d8 Deep blue #0077b6 Clean look
Lava Hot aggressive Orange #ff6b35 Red #d90429 High energy
Frost Soft pastel Light blue #a2d2ff Pale blue #bde0fe Light charts
Neon Maximum contrast Green #39ff14 Red #ff073a Visibility
Each theme defines a coordinated 7-color palette (upper, lower, basis, bull, bear, squeeze, accent) so everything matches.
5.2 Glow Effect
Three concentric layers are drawn behind each band line:
Layer Opacity Width Effect
Outer glow 92% transparent 6px Soft ambient halo
Mid glow 82% transparent 4px Intermediate diffusion
Inner glow 60% transparent 2px Concentrated glow
Core line 0% transparent 1px Sharp band edge
This creates a neon light tube effect around each band.
5.3 Zone Fills
Five separate fill regions create depth:
Zone Between Opacity Meaning
Upper zone Upper band → Inner upper 88% Overbought territory
Lower zone Lower band → Inner lower 88% Oversold territory
Core zone Inner upper → Inner lower 95% Fair value area
Upper half Upper band → LMA 94% Subtle upper bias tint
Lower half Lower band → LMA 94% Subtle lower bias tint
5.4 Dynamic Basis Color
The LMA line color shifts in real-time based on price position:
When price is near the lower band → basis turns lower band color
When price is near the upper band → basis turns upper band color
This creates an instant visual read of where price sits
5.5 Signal Visualization (Triple-Layer)
Each signal has three visual layers for maximum clarity:
Layer Element Purpose
Primary Large ▲/▼ triangle with bold "LONG"/"SHORT" text Unmissable directional signal
Accent Small circle dot at the same location Adds visual weight and layering
Context Dotted horizontal line spanning ±1 bar Marks the exact price level of the signal
Background Full-bar bgcolor tint (green/red) Makes signal bars visible even when zoomed out
5.6 Band Touch Markers
Small xcross shapes appear when price first touches a band without triggering a full signal. These serve as early warnings that price is testing an extreme.
5.7 LMA Dot Trail (Optional)
When enabled, alternating dots • appear on the LMA line every other bar, creating a stylized beaded line effect instead of a solid line.
6. DASHBOARD
A real-time information panel displayed in the corner with alternating dark row backgrounds:
Row Left Column Right Column Color Logic
Header ⚡ LIQUIDITY BANDS ━━━━━━ Theme accent
Theme Theme Active theme name + ● Upper band color
Mode Mode Active signal mode Accent color
Width Width Band width as % Orange if squeeze, green if expanding, gray if normal
Status Status ⊘ SQUEEZE / ⊕ EXPANDING / ◎ NORMAL Contextual color
Price Price ▲ ABOVE / ▼ BELOW / ◈ INSIDE Green/red/white
Ratio Ratio ████░░░░░░ 40% gauge bar Gradient from lower to upper band color
7. ALERTS
Alert Fires When
Long Signal Any long condition triggers (based on selected mode)
Short Signal Any short condition triggers (based on selected mode)
LMA Cross Up Price crosses above the LMA
LMA Cross Down Price crosses below the LMA
Squeeze Band width hits squeeze threshold
All alert messages include the ticker symbol via {{ticker}}.
8. INPUT REFERENCE
Input Default Range Description
Lookback Length 20 1+ Number of bars for LMA and std dev calculation
StdDev Multiplier 2.0 0.1+ Width of outer bands (higher = wider)
Price Source Close Any Which price to use for calculations
Inner Band Multiplier 1.0 0.1+ Width of inner bands
Signal Mode Mean Reversion 3 options Which signal logic to use
Show Signals ✓ Toggle Display signal markers
Show LMA Cross ✗ Toggle Display LMA cross diamonds
Color Theme Cyber 5 options Visual color scheme
Band Glow Effect
Liquidity Bands is a volume-weighted volatility envelope indicator. Unlike standard Bollinger Bands that use a Simple Moving Average and equal-weighted standard deviation, this indicator weights every price observation by its liquidity (volume × true range). This means:
High-volume, high-volatility bars have a stronger influence on the bands
Low-volume, quiet bars contribute less to the calculation
The bands naturally gravitate toward price levels where real trading activity occurred
This makes the bands more responsive to institutional activity and genuine supply/demand zones rather than treating every bar equally.
2. CORE CALCULATIONS
2.1 Liquidity Proxy
text
liquidity = volume × true_range
Each bar's "weight" is determined by multiplying its volume by its true range. This captures dollar-flow intensity — a bar with high volume AND wide range represents significant market participation. If volume is unavailable (e.g., some crypto pairs), it defaults to 1 so the indicator still functions.
2.2 Liquidity-Weighted Moving Average (LMA)
text
LMA = Σ(price × liquidity, n) / Σ(liquidity, n)
Instead of a simple average where each bar counts equally, the LMA is a weighted mean where high-liquidity bars pull the average toward their price level more strongly. This is the center line (basis) of the bands.
Interpretation:
LMA represents the fair value based on where the most trading activity occurred
Price above LMA → bullish bias
Price below LMA → bearish bias
2.3 Liquidity-Weighted Standard Deviation
text
variance = Σ(price² × liquidity, n) / Σ(liquidity, n) − LMA²
std_dev = √variance
The standard deviation is also liquidity-weighted, meaning volatility is measured relative to where liquidity actually participated, not just raw price swings.
2.4 Band Construction
Band Formula Purpose
Upper Band LMA + (mult × std_dev) Overbought / resistance zone
Lower Band LMA − (mult × std_dev) Oversold / support zone
Inner Upper LMA + (inner_mult × std_dev) First standard deviation — early warning
Inner Lower LMA − (inner_mult × std_dev) First standard deviation — early warning
Default multipliers: Outer = 2.0, Inner = 1.0
This creates four zones:
Above upper band → extreme overbought
Upper band to inner upper → overbought zone
Inner upper to inner lower → neutral / fair value zone
Inner lower to lower band → oversold zone
Below lower band → extreme oversold
3. SIGNAL MODES
3.1 Mean Reversion Mode
Philosophy: Price tends to return to the mean after touching extremes.
Signal Condition Logic
LONG Previous close was at or below the lower band, current close is back above it Price was rejected at the lower extreme and is recovering — buy the bounce
SHORT Previous close was at or above the upper band, current close is back below it Price was rejected at the upper extreme and is fading — sell the rejection
Best used in: Ranging/sideways markets, mean-reverting instruments, when squeeze is active.
3.2 Breakout Mode
Philosophy: When price breaks through the bands with conviction, momentum follows.
Signal Condition Logic
LONG Price crosses above the upper band Bullish momentum breakout — buy the strength
SHORT Price crosses below the lower band Bearish momentum breakdown — sell the weakness
Best used in: Trending markets, after a squeeze, high-momentum instruments.
3.3 Both Mode
Fires signals from either mode. Useful for scanning all opportunities but requires additional context/filtering to avoid conflicting signals.
3.4 LMA Cross Signals (Optional)
Signal Condition
Cross Up Price crosses above the LMA basis line
Cross Down Price crosses below the LMA basis line
These are secondary/confirmation signals — a diamond shape appears. Useful for:
Confirming a mean reversion signal (price bounced off band AND crossed back above LMA)
Identifying trend direction shifts
4. BAND WIDTH & SQUEEZE DETECTION
4.1 Band Width
text
band_width = (upper_band − lower_band) / LMA × 100
Expressed as a percentage of the LMA, this normalizes volatility across different price levels and instruments. A 5% band width means the bands span 5% of the current price level.
4.2 Squeeze Detection
text
squeeze = band_width < lowest(band_width, 50) × 1.05
A squeeze is detected when the current band width is within 5% of the lowest band width in the last 50 bars. This means volatility has contracted to near-historic lows for the recent window.
What it means:
Energy is building — a large move is likely coming
Direction is unknown — wait for breakout confirmation
Displayed as a soft orange/yellow background tint across the chart
4.3 Expansion Detection
text
expansion = band_width > highest(band_width[1], 20) × 0.95
Bands are expanding when width is near the 20-bar high. This confirms an active trend/momentum move is underway.
4.4 Price Position Ratio
text
ratio = (close − lower_band) / (upper_band − lower_band)
Gives a 0–100% reading of where price sits within the bands:
0% = at the lower band
50% = at the LMA
100% = at the upper band
>100% = above upper band
<0% = below lower band
Displayed as a visual gauge bar ████░░░░░░ 40% in the dashboard.
5. VISUAL SYSTEM
5.1 Color Themes
Theme Character Upper Lower Best For
Cyber Futuristic neon Cyan #00e5ff Pink #ff006e Dark charts
Ocean Cool aquatic Teal #00b4d8 Deep blue #0077b6 Clean look
Lava Hot aggressive Orange #ff6b35 Red #d90429 High energy
Frost Soft pastel Light blue #a2d2ff Pale blue #bde0fe Light charts
Neon Maximum contrast Green #39ff14 Red #ff073a Visibility
Each theme defines a coordinated 7-color palette (upper, lower, basis, bull, bear, squeeze, accent) so everything matches.
5.2 Glow Effect
Three concentric layers are drawn behind each band line:
Layer Opacity Width Effect
Outer glow 92% transparent 6px Soft ambient halo
Mid glow 82% transparent 4px Intermediate diffusion
Inner glow 60% transparent 2px Concentrated glow
Core line 0% transparent 1px Sharp band edge
This creates a neon light tube effect around each band.
5.3 Zone Fills
Five separate fill regions create depth:
Zone Between Opacity Meaning
Upper zone Upper band → Inner upper 88% Overbought territory
Lower zone Lower band → Inner lower 88% Oversold territory
Core zone Inner upper → Inner lower 95% Fair value area
Upper half Upper band → LMA 94% Subtle upper bias tint
Lower half Lower band → LMA 94% Subtle lower bias tint
5.4 Dynamic Basis Color
The LMA line color shifts in real-time based on price position:
When price is near the lower band → basis turns lower band color
When price is near the upper band → basis turns upper band color
This creates an instant visual read of where price sits
5.5 Signal Visualization (Triple-Layer)
Each signal has three visual layers for maximum clarity:
Layer Element Purpose
Primary Large ▲/▼ triangle with bold "LONG"/"SHORT" text Unmissable directional signal
Accent Small circle dot at the same location Adds visual weight and layering
Context Dotted horizontal line spanning ±1 bar Marks the exact price level of the signal
Background Full-bar bgcolor tint (green/red) Makes signal bars visible even when zoomed out
5.6 Band Touch Markers
Small xcross shapes appear when price first touches a band without triggering a full signal. These serve as early warnings that price is testing an extreme.
5.7 LMA Dot Trail (Optional)
When enabled, alternating dots • appear on the LMA line every other bar, creating a stylized beaded line effect instead of a solid line.
6. DASHBOARD
A real-time information panel displayed in the corner with alternating dark row backgrounds:
Row Left Column Right Column Color Logic
Header ⚡ LIQUIDITY BANDS ━━━━━━ Theme accent
Theme Theme Active theme name + ● Upper band color
Mode Mode Active signal mode Accent color
Width Width Band width as % Orange if squeeze, green if expanding, gray if normal
Status Status ⊘ SQUEEZE / ⊕ EXPANDING / ◎ NORMAL Contextual color
Price Price ▲ ABOVE / ▼ BELOW / ◈ INSIDE Green/red/white
Ratio Ratio ████░░░░░░ 40% gauge bar Gradient from lower to upper band color
7. ALERTS
Alert Fires When
Long Signal Any long condition triggers (based on selected mode)
Short Signal Any short condition triggers (based on selected mode)
LMA Cross Up Price crosses above the LMA
LMA Cross Down Price crosses below the LMA
Squeeze Band width hits squeeze threshold
All alert messages include the ticker symbol via {{ticker}}.
8. INPUT REFERENCE
Input Default Range Description
Lookback Length 20 1+ Number of bars for LMA and std dev calculation
StdDev Multiplier 2.0 0.1+ Width of outer bands (higher = wider)
Price Source Close Any Which price to use for calculations
Inner Band Multiplier 1.0 0.1+ Width of inner bands
Signal Mode Mean Reversion 3 options Which signal logic to use
Show Signals ✓ Toggle Display signal markers
Show LMA Cross ✗ Toggle Display LMA cross diamonds
Color Theme Cyber 5 options Visual color scheme
Band Glow Effect
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน