OPEN-SOURCE SCRIPT
Telah dikemas kini

Enhanced Volume Trend Indicator with BB Squeeze

101
Enhanced Volume Trend Indicator with BB Squeeze: Comprehensive Explanation
The visualization system allows traders to quickly scan multiple securities to identify high-probability setups without detailed analysis of each chart. The progression from squeeze to breakout, supported by volume trend confirmation, offers a systematic approach to identifying trading opportunities.

The script combines multiple technical analysis approaches into a comprehensive dashboard that helps traders make informed decisions by identifying high-probability setups while filtering out noise through its sophisticated confirmation requirements. It combines multiple technical analysis approaches into an integrated visual system that helps traders identify potential trading opportunities while filtering out false signals.

Core Features
1. Volume Analysis Dashboard
The indicator displays various volume-related metrics in customizable tables:

AVOL (After Hours + Pre-Market Volume): Shows extended hours volume as a percentage of the 21-day average volume with color coding for buying/selling pressure. Green indicates buying pressure and red indicates selling pressure.
Volume Metrics: Includes regular volume (VOL), dollar volume ($VOL), relative volume compared to 21-day average (RVOL), and relative volume compared to 90-day average (RVOL90D).
Pre-Market Data: Optional display of pre-market volume (PVOL), pre-market dollar volume (P$VOL), pre-market relative volume (PRVOL), and pre-market price change percentage (PCHG%).

2. Enhanced Volume Trend (VTR) Analysis
The Volume Trend indicator uses adaptive analysis to evaluate buying and selling pressure, combining multiple factors:

MACD (Moving Average Convergence Divergence) components
Volume-to-SMA (Simple Moving Average) ratio
Price direction and market conditions
Volume change rates and momentum
EMA (Exponential Moving Average) alignment and crossovers
Volatility filtering

VTR Visual Indicators
The VTR score ranges from 0-100, with values above 50 indicating bullish conditions and below 50 indicating bearish conditions. This is visually represented by colored circles:

"●" (Filled Circle):

Green: Strong bullish trend (VTR ≥ 80)
Red: Strong bearish trend (VTR ≤ 20)


"◯" (Hollow Circle):

Green: Moderate bullish trend (VTR 65-79)
Red: Moderate bearish trend (VTR 21-35)


"·" (Small Dot):

Green: Weak bullish trend (VTR 55-64)
Red: Weak bearish trend (VTR 36-45)


"○" (Medium Hollow Circle): Neutral conditions (VTR 46-54), shown in gray

In "Both" display mode, the VTR shows both the numerical score (0-100) alongside the appropriate circle symbol.
Enhanced VTR Settings
The Enhanced Volume Trend component offers several advanced customization options:

Adaptive Volume Analysis (volTrendAdaptive):

When enabled, dynamically adjusts volume thresholds based on recent market volatility
Higher volatility periods require proportionally higher volume to generate significant signals
Helps prevent false signals during highly volatile markets
Keep enabled for most trading conditions, especially in volatile markets


Speed of Change Weight (volTrendSpeedWeight, range 0-1):

Controls emphasis on volume acceleration/deceleration rather than absolute levels
Higher values (0.7-1.0): More responsive to new volume trends, better for momentum trading
Lower values (0.2-0.5): Less responsive, better for trend following
Helps identify early volume trends before they fully develop


Momentum Period (volTrendMomentumPeriod, range 2-10):

Defines lookback period for volume change rate calculations
Lower values (2-3): More responsive to recent changes, better for short timeframes
Higher values (7-10): Smoother, better for daily/weekly charts
Directly affects how quickly the indicator responds to new volume patterns


Volatility Filter (volTrendVolatilityFilter):

Adjusts significance of volume by factoring in current price volatility
High volume during high volatility receives less weight
High volume during low volatility receives more weight
Helps distinguish between genuine volume-driven moves and volatility-driven moves


EMA Alignment Weight (volTrendEmaWeight, range 0-1):

Controls importance of EMA alignments in final VTR calculation
Analyzes multiple EMA relationships (5, 10, 21 period)
Higher values (0.7-1.0): Greater emphasis on trend structure
Lower values (0.2-0.5): More focus on pure volume patterns


Display Mode (volTrendDisplayMode):

"Value": Shows only numerical score (0-100)
"Strength": Shows only symbolic representation
"Both": Shows numerical score and symbol together



3. Bollinger Band Squeeze Detection (SQZ)
The BB Squeeze indicator identifies periods of low volatility when Bollinger Bands contract inside Keltner Channels, often preceding significant price movements.
SQZ Visual Indicators

"●" (Filled Circle): Strong squeeze - high probability setup for an impending breakout

Green: Strong squeeze with bullish bias (likely upward breakout)
Red: Strong squeeze with bearish bias (likely downward breakout)
Orange: Strong squeeze with unclear direction


"◯" (Hollow Circle): Moderate squeeze - medium probability setup

Green: With bullish EMA alignment
Red: With bearish EMA alignment
Orange: Without clear directional bias


"-" (Dash): Gray dash indicates no squeeze condition (normal volatility)

The script identifies squeeze conditions through multiple methods:

Bollinger Bands contracting inside Keltner Channels
BB width falling to bottom 20% of recent range (BB width percentile)
Very narrow Keltner Channel (less than 5% of basis price)
Tracking squeeze duration in consecutive bars

Different squeeze strengths are detected:

Strong Squeeze: BB inside KC with tight BB width and narrow KC
Moderate Squeeze: BB inside KC with either tight BB width or narrow KC
No Squeeze: Normal market conditions

4. Breakout Detection System
The script includes two breakout indicators working in sequence:
4.1 Pre-Breakout (PBK) Indicator
Detects potential upcoming breakouts by analyzing multiple factors:

Squeeze conditions lasting 2-3 bars or more
Significant price ranges
Strong volume confirmation
EMA/MACD crossovers
Consistent price direction

PBK Visual Indicators

"●" (Filled Circle): Detected pre-breakout condition

Green: Likely upward breakout (bullish)
Red: Likely downward breakout (bearish)
Orange: Direction not yet clear, but breakout likely


"-" (Dash): Gray dash indicates no pre-breakout condition

The PBK uses sophisticated conditions to reduce false signals including minimum squeeze length, significant price movement, and technical confirmations.
4.2 Breakout (BK) Indicator
Confirms actual breakouts in progress by identifying:

End of squeeze or strong expansion of Bollinger Bands
Volume expansion
Price moving outside Bollinger Bands
EMA crossovers with volume confirmation
MACD crossovers with significant price range

BK Visual Indicators

"●" (Filled Circle): Confirmed breakout in progress

Green: Upward breakout (bullish)
Red: Downward breakout (bearish)
Orange: Unusual breakout pattern without clear direction


"◆" (Diamond): Special breakout conditions (meets some but not all criteria)
"-" (Dash): Gray dash indicates no breakout detected

The BK indicator uses advanced filters for confirmation:

Requires consecutive breakout signals to reduce false positives
Strong volume confirmation requirements (40% above average)
Significant price movement thresholds
Consistency checks between price action and indicators

5. Market Metrics and Analysis
Price Change Percentage (CHG%)
Displays the current percentage change relative to the previous day's close, color-coded green for positive changes and red for negative changes.
Average Daily Range (ADR%)
Calculates the average daily percentage range over a specified period (default 20 days), helping traders gauge volatility and set appropriate price targets.
Average True Range (ATR)
Shows the Average True Range value, a volatility indicator developed by J. Welles Wilder that measures market volatility by decomposing the entire range of an asset price for that period.
Relative Strength Index (RSI)
Displays the standard 14-period RSI, a momentum oscillator that measures the speed and change of price movements on a scale from 0 to 100.
6. External Market Indicators
QQQ Change
Shows the percentage change in the Invesco QQQ Trust (tracking the Nasdaq-100 Index), useful for understanding broader tech market trends.
UVIX Change
Displays the percentage change in UVIX, a volatility index, providing insight into market fear and potential hedging activity.
BTC-USD
Shows the current Bitcoin price from Coinbase, useful for traders monitoring crypto correlation with equities.
Market Breadth (BRD)
Calculates the percentage difference between ATHI.US and ATLO.US (high vs. low securities), indicating overall market direction and strength.
7. Session Analysis and Volume Direction
Session Detection
The script accurately identifies different market sessions:

Pre-market: 4:00 AM to 9:30 AM
Regular market: 9:30 AM to 4:00 PM
After-hours: 4:00 PM to 8:00 PM
Closed: Outside trading hours

This detection works on any timeframe through careful calculation of current time in seconds.
Buy/Sell Volume Direction
The script analyzes buying and selling pressure by:

Counting up volume when close > open
Counting down volume when close < open
Tracking accumulated volume within the day
Calculating intraday pressure (up volume minus down volume)

Enhanced AVOL Calculation
The improved AVOL calculation works in all timeframes by:

Estimating typical pre-market and after-hours volume percentages
Combining yesterday's after-hours with today's pre-market volume
Calculating this as a percentage of the 21-day average volume
Determining buying/selling pressure by analyzing after-hours and pre-market price changes
Color-coding results: green for buying pressure, red for selling pressure

This calculation is particularly valuable because it works consistently across any timeframe.
Customization Options
Display Settings
The dashboard has two customizable tables: Volume Table and Metrics Table, with positions selectable as bottom_left or bottom_right.
All metrics can be individually toggled on/off:

Pre-market data (PVOL, P$VOL, PRVOL, PCHG%)
Volume data (AVOL, RVOL Day, RVOL 90D, Volume, VVOLUME)
Price metrics (ADR%, ATR, RSI, Price Change%)
Market indicators (QQQ, UVIX, Breadth, BTC-USD)
Analysis indicators (Volume Trend, BB Squeeze, Pre-Breakout, Breakout)

These toggle options allow traders to customize the dashboard to show only the metrics they find most valuable for their trading style.
Table and Text Customization
The dashboard's appearance can be customized:

Table background color via tableBgColor
Text color (White or Black) via textColorOption

The indicator uses smart formatting for volume and price values, automatically adding appropriate suffixes (K, M, B) for readability.
MACD Configuration for VTR
The Volume Trend calculation incorporates MACD with customizable parameters:

Fast Length: Controls the period for the fast EMA (default 3)
Slow Length: Controls the period for the slow EMA (default 9)
Signal Length: Controls the period for the signal line EMA (default 5)
MACD Weight: Controls how much influence MACD has on the volume trend score (default 0.3)

These settings allow traders to fine-tune how momentum is factored into the volume trend analysis.
Bollinger Bands and Keltner Channel Settings
The Bollinger Bands and Keltner Channels used for squeeze detection have preset (hidden) parameters:

BB Length: 20 periods
BB Multiplier: 2.0 standard deviations
Keltner Length: 20 periods
Keltner Multiplier: 1.5 ATR

These settings follow standard practice for squeeze detection while maintaining simplicity in the user interface.
Practical Trading Applications
Complete Trading Strategies
1. Squeeze Breakout Strategy
This strategy combines multiple components of the indicator:

Wait for a strong squeeze (SQZ showing ●)
Look for pre-breakout confirmation (PBK showing ● in green or red)
Enter when breakout is confirmed (BK showing ● in same direction)
Use VTR to confirm volume supports the move (VTR ≥ 65 for bullish or ≤ 35 for bearish)
Set profit targets based on ADR (Average Daily Range)
Exit when VTR begins to weaken or changes direction

2. Volume Divergence Strategy
This strategy focuses on the volume trend relative to price:

Identify when price makes a new high but VTR fails to confirm (divergence)
Look for VTR to show weakening trend (● changing to ◯ or ·)
Prepare for potential reversal when SQZ begins to form
Enter counter-trend position when PBK confirms reversal direction
Use external indicators (QQQ, BTC, Breadth) to confirm broader market support

3. Pre-Market Edge Strategy
This strategy leverages pre-market data:

Monitor AVOL for unusual pre-market activity (significantly above 100%)
Check pre-market price change direction (PCHG%)
Enter position at market open if VTR confirms direction
Use SQZ to determine if volatility is likely to expand
Exit based on RVOL declining or price reaching +/- ADR for the day

Market Context Integration
The indicator provides valuable context for trading decisions:

QQQ change shows tech market direction
BTC price shows crypto market correlation
UVIX change indicates volatility expectations
Breadth measurement shows market internals

This context helps traders avoid fighting the broader market and align trades with overall market direction.
Timeframe Optimization
The indicator is designed to work across different timeframes:

For day trading: Focus on AVOL, VTR, PBK/BK, and use shorter momentum periods
For swing trading: Focus on SQZ duration, VTR strength, and broader market indicators
For position trading: Focus on larger VTR trends and use EMA alignment weight

Advanced Analytical Components
Enhanced Volume Trend Score Calculation
The VTR score calculation is sophisticated, with the base score starting at 50 and adjusting for:

Price direction (up/down)
Volume relative to average (high/normal/low)
Volume acceleration/deceleration
Market conditions (bull/bear)

Additional factors are then applied, including:

MACD influence weighted by strength and direction
Volume change rate influence (speed)
Price/volume divergence effects
EMA alignment scores
Volatility adjustments
Breakout strength factors
Price action confirmations

The final score is clamped between 0-100, with values above 50 indicating bullish conditions and below 50 indicating bearish conditions.
Anti-False Signal Filters
The indicator employs multiple techniques to reduce false signals:

Requiring significant price range (minimum percentage movement)
Demanding strong volume confirmation (significantly above average)
Checking for consistent direction across multiple indicators
Requiring prior bar consistency (consecutive bars moving in same direction)
Counting consecutive signals to filter out noise

These filters help eliminate noise and focus on high-probability setups.
MACD Enhancement and Integration
The indicator enhances standard MACD analysis:

Calculating MACD relative strength compared to recent history
Normalizing MACD slope relative to volatility
Detecting MACD acceleration for stronger signals
Integrating MACD crossovers with other confirmation factors

EMA Analysis System
The indicator uses a comprehensive EMA analysis system:

Calculating multiple EMAs (5, 10, 21 periods)
Detecting golden cross (10 EMA crosses above 21 EMA)
Detecting death cross (10 EMA crosses below 21 EMA)
Assessing price position relative to EMAs
Measuring EMA separation percentage

Recent Enhancements and Evolution
Version 5.2 includes several improvements:

Enhanced AVOL to show buying/selling direction through color coding
Improved VTR with adaptive analysis based on market conditions
AVOL display now works in all timeframes through sophisticated estimation
Removed animal symbols and streamlined code with bright colors for better visibility
Improved anti-false signal filters throughout the system

Optimizing Indicator Settings
For Different Market Types
Range-Bound Markets:

Lower EMA Alignment Weight (0.2-0.4)
Higher Speed of Change Weight (0.8-1.0)
Focus on SQZ and PBK signals for breakout potential

Trending Markets:

Higher EMA Alignment Weight (0.7-1.0)
Moderate Speed of Change Weight (0.4-0.6)
Focus on VTR strength and BK confirmations

Volatile Markets:

Enable Volatility Filter
Enable Adaptive Volume Analysis
Lower Momentum Period (2-3)
Focus on strong volume confirmation (VTR ≥ 80 or ≤ 20)

For Different Asset Classes
Equities:

Standard settings work well
Pay attention to AVOL for gap potential
Monitor QQQ correlation

Futures:

Consider higher Volume/RVOL weight
Reduce MACD weight slightly
Pay close attention to SQZ duration

Crypto:

Higher volatility thresholds may be needed
Monitor BTC price for correlation
Focus on stronger confirmation signals

Integrated Visual System for Trading Decisions
The colored circle indicators create an intuitive visual system for quick market assessment:

Progression Sequence: SQZ (Squeeze) → PBK (Pre-Breakout) → BK (Breakout)
This sequence often occurs in order, with the squeeze leading to pre-breakout conditions, followed by an actual breakout.
VTR (Volume Trend): Provides context about the volume supporting these movements.
Color Coding: Green for bullish conditions, red for bearish conditions, and orange/gray for neutral or undefined conditions.
Nota Keluaran
Updated VTR, SQZ, PBK and BK to work in pre-market.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.