OPEN-SOURCE SCRIPT
Volume Weighted Trend [QuantAlgo]

๐ข Overview
The Volume Weighted Trend indicator identifies statistically significant trend changes by combining volume-weighted price analysis with volatility-based breakout bands. It calculates a Volume Weighted Moving Average (VWMA) as the central trend baseline, then creates dynamic upper and lower bands using Average True Range (ATR) multipliers to define normal volatility boundaries. When price breaks above the upper band or below the lower band, it signals a confirmed trend change, helping traders and investors identify directional shifts driven by both volume-weighted momentum and volatility expansion across different timeframes and markets.

๐ข How It Works
The indicator's core methodology lies in its dual-layer approach combining volume weighting with volatility filtering, where trend changes require both price direction and statistical significance:
Pine Scriptยฎ
First, the script calculates the Volume Weighted Moving Average to establish a trend baseline that gives greater weight to periods with higher trading volume, ensuring the trend line reflects significant participation and genuine market conviction rather than low-volume noise.
Then, it measures the Average True Range over the same period to quantify current market volatility:
Pine Scriptยฎ
Next, dynamic volatility bands are constructed by adding and subtracting ATR-based buffers from the VWMA baseline, creating adaptive boundaries that expand during volatile conditions and contract during calm periods:
Pine Scriptยฎ
The trend state is then determined through breakout logic that requires price to exceed these volatility-adjusted boundaries:
Pine Scriptยฎ
Finally, trend change detection identifies transitions between bullish and bearish states:
Pine Scriptยฎ
This creates a robust trend-following system that only signals directional changes when price makes statistically significant moves beyond normal volatility bounds, with volume weighting ensuring the trend reflects meaningful market activity rather than thin-volume spikes.

๐ข Signal Interpretation
โถ Bullish Trend (Price Above Upper Band): When price closes above the upper volatility band, the indicator switches to bullish mode with green/bullish coloring throughout all visual elements = Confirmed uptrend signal for trend-following long positions. The trend remains bullish until price breaks below the lower band, allowing traders to stay positioned during sustained upward momentum without premature exits on minor pullbacks within the band range.
โถ Bearish Trend (Price Below Lower Band): When price closes below the lower volatility band, the indicator switches to bearish mode with red/bearish coloring throughout all visual elements = Confirmed downtrend signal for trend-following short positions or long exit signals. The trend remains bearish until price breaks above the upper band, enabling traders to maintain directional bias through corrective moves that stay within the band boundaries.
โถ Neutral Zone (Price Between Bands): When price trades between the upper and lower volatility bands, the indicator maintains its previous trend direction = Continuation of existing trend during consolidation or normal volatility retracements. This design prevents whipsaws during sideways action by requiring price to make a significant move beyond opposite-side bands to trigger trend reversal, rather than flip-flopping on minor crosses of the VWMA center line.

๐ข Features
โถ Preconfigured Presets: Three optimized parameter sets for different trading approaches and timeframes. "Default" provides balanced trend detection for swing trading on 4-hour and daily charts, filtering noise effectively while capturing meaningful trend changes. "Fast Response" delivers quicker trend signals for intraday trading on 5-minute to 1-hour charts, with tighter bands triggering earlier on breakouts for active traders who can monitor positions closely. "Smooth Trend" focuses on major trend changes for position trading on daily to weekly timeframes, with wider bands filtering out minor fluctuations to identify only primary directional shifts.

โถ Built-in Alerts: Three alert conditions enable automated monitoring of trend changes without constant chart watching. "Bullish Trend Signal" triggers when the indicator switches to bullish mode after price breaks above the upper band, alerting for potential long entries. "Bearish Trend Signal" activates when the indicator switches to bearish mode after price breaks below the lower band, signaling potential short entries or long exits. "Trend Direction Changed" provides a combined alert for any trend transition regardless of direction, allowing traders to monitor both bullish and bearish opportunities with a single alert setup.

โถ Visual Customization: Six color presets (Classic, Aqua, Cosmic, Cyber, Neon, plus Custom) accommodate different chart backgrounds and aesthetic preferences, with coordinated bullish and bearish color schemes applied across all indicator elements. Optional neon glow effect creates layered visual emphasis around the central VWMA line with three overlapping plots at different transparencies, making the trend line more prominent and easier to track (ideal for charts with multiple indicators where visual distinction is important). Optional volatility ribbons display gradient fills between the VWMA and band boundaries, providing visual context for price position relative to breakout thresholds with adjustable band transparency (0-100%) to control prominence. Optional bar coloring tints price bars with trend-appropriate colors during bullish and bearish periods, enabling instant visual confirmation of trend state across multiple timeframes without switching between chart and indicator panels.

The Volume Weighted Trend indicator identifies statistically significant trend changes by combining volume-weighted price analysis with volatility-based breakout bands. It calculates a Volume Weighted Moving Average (VWMA) as the central trend baseline, then creates dynamic upper and lower bands using Average True Range (ATR) multipliers to define normal volatility boundaries. When price breaks above the upper band or below the lower band, it signals a confirmed trend change, helping traders and investors identify directional shifts driven by both volume-weighted momentum and volatility expansion across different timeframes and markets.
๐ข How It Works
The indicator's core methodology lies in its dual-layer approach combining volume weighting with volatility filtering, where trend changes require both price direction and statistical significance:
vwma_basis = ta.vwma(close, vwma_length)
atr_value = ta.atr(vwma_length)
upper_band = vwma_basis + atr_value * atr_multiplier
lower_band = vwma_basis - atr_value * atr_multiplier
First, the script calculates the Volume Weighted Moving Average to establish a trend baseline that gives greater weight to periods with higher trading volume, ensuring the trend line reflects significant participation and genuine market conviction rather than low-volume noise.
Then, it measures the Average True Range over the same period to quantify current market volatility:
atr_value = ta.atr(vwma_length)
Next, dynamic volatility bands are constructed by adding and subtracting ATR-based buffers from the VWMA baseline, creating adaptive boundaries that expand during volatile conditions and contract during calm periods:
upper_band = vwma_basis + atr_value * atr_multiplier
lower_band = vwma_basis - atr_value * atr_multiplier
The trend state is then determined through breakout logic that requires price to exceed these volatility-adjusted boundaries:
if close > upper_band
trend_direction := 1
else if close < lower_band
trend_direction := -1
Finally, trend change detection identifies transitions between bullish and bearish states:
trend_turned_bullish = trend_direction == 1 and trend_direction[1] != 1
trend_turned_bearish = trend_direction == -1 and trend_direction[1] != -1
This creates a robust trend-following system that only signals directional changes when price makes statistically significant moves beyond normal volatility bounds, with volume weighting ensuring the trend reflects meaningful market activity rather than thin-volume spikes.
๐ข Signal Interpretation
โถ Bullish Trend (Price Above Upper Band): When price closes above the upper volatility band, the indicator switches to bullish mode with green/bullish coloring throughout all visual elements = Confirmed uptrend signal for trend-following long positions. The trend remains bullish until price breaks below the lower band, allowing traders to stay positioned during sustained upward momentum without premature exits on minor pullbacks within the band range.
โถ Bearish Trend (Price Below Lower Band): When price closes below the lower volatility band, the indicator switches to bearish mode with red/bearish coloring throughout all visual elements = Confirmed downtrend signal for trend-following short positions or long exit signals. The trend remains bearish until price breaks above the upper band, enabling traders to maintain directional bias through corrective moves that stay within the band boundaries.
โถ Neutral Zone (Price Between Bands): When price trades between the upper and lower volatility bands, the indicator maintains its previous trend direction = Continuation of existing trend during consolidation or normal volatility retracements. This design prevents whipsaws during sideways action by requiring price to make a significant move beyond opposite-side bands to trigger trend reversal, rather than flip-flopping on minor crosses of the VWMA center line.
๐ข Features
โถ Preconfigured Presets: Three optimized parameter sets for different trading approaches and timeframes. "Default" provides balanced trend detection for swing trading on 4-hour and daily charts, filtering noise effectively while capturing meaningful trend changes. "Fast Response" delivers quicker trend signals for intraday trading on 5-minute to 1-hour charts, with tighter bands triggering earlier on breakouts for active traders who can monitor positions closely. "Smooth Trend" focuses on major trend changes for position trading on daily to weekly timeframes, with wider bands filtering out minor fluctuations to identify only primary directional shifts.
โถ Built-in Alerts: Three alert conditions enable automated monitoring of trend changes without constant chart watching. "Bullish Trend Signal" triggers when the indicator switches to bullish mode after price breaks above the upper band, alerting for potential long entries. "Bearish Trend Signal" activates when the indicator switches to bearish mode after price breaks below the lower band, signaling potential short entries or long exits. "Trend Direction Changed" provides a combined alert for any trend transition regardless of direction, allowing traders to monitor both bullish and bearish opportunities with a single alert setup.
โถ Visual Customization: Six color presets (Classic, Aqua, Cosmic, Cyber, Neon, plus Custom) accommodate different chart backgrounds and aesthetic preferences, with coordinated bullish and bearish color schemes applied across all indicator elements. Optional neon glow effect creates layered visual emphasis around the central VWMA line with three overlapping plots at different transparencies, making the trend line more prominent and easier to track (ideal for charts with multiple indicators where visual distinction is important). Optional volatility ribbons display gradient fills between the VWMA and band boundaries, providing visual context for price position relative to breakout thresholds with adjustable band transparency (0-100%) to control prominence. Optional bar coloring tints price bars with trend-appropriate colors during bullish and bearish periods, enabling instant visual confirmation of trend state across multiple timeframes without switching between chart and indicator panels.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalitร . Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice รจ soggetta al nostro Regolamento.
๐ Access our best trading & investing tools here (3-day FREE trial): whop.com/quantalgo/
Declinazione di responsabilitร
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalitร . Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice รจ soggetta al nostro Regolamento.
๐ Access our best trading & investing tools here (3-day FREE trial): whop.com/quantalgo/
Declinazione di responsabilitร
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.