OPEN-SOURCE SCRIPT
Intraday Sentiment Dynamics

The purpose of this script is to create a structured model of intraday sentiment by analyzing how price behaves relative to VWAP. Instead of treating VWAP deviation as a simple overbought or oversold measure, the script aims to understand the dynamics behind that deviation — how quickly sentiment is shifting, whether that shift is strengthening or weakening, and when abrupt changes in behaviour occur. Its goal is to provide a standardized, volatility‑adjusted framework that helps traders identify trend continuation, trend exhaustion, mean‑reversion setups, and early regime shifts.
To achieve this, the script begins by calculating the difference between the bar’s midpoint and VWAP. This raw deviation is then standardized using a rolling mean and standard deviation, producing a z‑score that expresses how far price is from VWAP in statistical terms. Standardization removes volatility bias, session drift, and asset‑specific scaling issues, making the signal comparable across different market conditions. A weighted moving average smooths this standardized deviation to reduce noise and prepare it for slope‑based analysis.
The core of the script is a slope‑normalization mechanism that measures how the standardized VWAP deviation changes over time. For each bar, the script computes the slope over a user‑defined length, separates positive and negative slope events, and maintains these in arrays that track their recent behaviour. From these arrays, it calculates average magnitudes and standard deviations, allowing it to normalize the current slope into a consistent, volatility‑adjusted scale. This ensures that both small and extreme slope events are interpreted meaningfully.
This normalization function is applied recursively to generate three higher‑order derivatives. The first derivative, velocity, represents the rate at which sentiment is moving toward or away from VWAP. The second derivative, acceleration, measures whether this movement is strengthening or weakening. The third derivative, jerk, captures sudden changes in acceleration and serves as an early indicator of shifts in market behaviour. Together, these derivatives form a multi‑layered behavioural model that reveals the internal structure of intraday sentiment.
The script visualizes these components using distinct color families and filled regions that highlight positive and negative behaviour. Background shading reinforces the dominant direction of each derivative, making it easy to see when sentiment is building, fading, or reversing. The standardized VWAP deviation is plotted alongside these derivatives, and horizontal lines at ±1, ±2, and ±3 standard deviations provide a statistical frame of reference for identifying extreme conditions.
In practical trading terms, the indicator helps identify strong continuation environments when velocity, acceleration, and jerk align in the same direction. It highlights early signs of trend exhaustion when jerk flips before acceleration, often preceding reversals. It supports mean‑reversion trades when VWAP deviation reaches extreme levels and the derivative chain begins to weaken. It also detects regime shifts when jerk spikes, helping traders avoid traps during sudden liquidity events or fake breakouts. By converting VWAP deviation into a structured, derivative‑based model, the script provides a clear and actionable view of intraday sentiment dynamics.
To achieve this, the script begins by calculating the difference between the bar’s midpoint and VWAP. This raw deviation is then standardized using a rolling mean and standard deviation, producing a z‑score that expresses how far price is from VWAP in statistical terms. Standardization removes volatility bias, session drift, and asset‑specific scaling issues, making the signal comparable across different market conditions. A weighted moving average smooths this standardized deviation to reduce noise and prepare it for slope‑based analysis.
The core of the script is a slope‑normalization mechanism that measures how the standardized VWAP deviation changes over time. For each bar, the script computes the slope over a user‑defined length, separates positive and negative slope events, and maintains these in arrays that track their recent behaviour. From these arrays, it calculates average magnitudes and standard deviations, allowing it to normalize the current slope into a consistent, volatility‑adjusted scale. This ensures that both small and extreme slope events are interpreted meaningfully.
This normalization function is applied recursively to generate three higher‑order derivatives. The first derivative, velocity, represents the rate at which sentiment is moving toward or away from VWAP. The second derivative, acceleration, measures whether this movement is strengthening or weakening. The third derivative, jerk, captures sudden changes in acceleration and serves as an early indicator of shifts in market behaviour. Together, these derivatives form a multi‑layered behavioural model that reveals the internal structure of intraday sentiment.
The script visualizes these components using distinct color families and filled regions that highlight positive and negative behaviour. Background shading reinforces the dominant direction of each derivative, making it easy to see when sentiment is building, fading, or reversing. The standardized VWAP deviation is plotted alongside these derivatives, and horizontal lines at ±1, ±2, and ±3 standard deviations provide a statistical frame of reference for identifying extreme conditions.
In practical trading terms, the indicator helps identify strong continuation environments when velocity, acceleration, and jerk align in the same direction. It highlights early signs of trend exhaustion when jerk flips before acceleration, often preceding reversals. It supports mean‑reversion trades when VWAP deviation reaches extreme levels and the derivative chain begins to weaken. It also detects regime shifts when jerk spikes, helping traders avoid traps during sudden liquidity events or fake breakouts. By converting VWAP deviation into a structured, derivative‑based model, the script provides a clear and actionable view of intraday sentiment dynamics.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que la republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.