OPEN-SOURCE SCRIPT

NVOL Normalized Volume & Volatility

Updated
OVERVIEW
Plots a normalized volume (or volatility) relative to a given bar's typical value across all charted sessions. The concept is similar to Relative Volume (RVOL) and Average True Range (ATR), but rather than using a moving average, this script uses bar data from previous sessions to more accurately separate what's normal from what's anomalous. Compatible on all timeframes and symbols.

Having volume and volatility processed within a single indicator not only allows you to toggle between the two for a consistent data display, it also allows you to measure how correlated they are. These measurements are available in the data table.


DATA & MATH
The core formula used to normalize each bar is:
( Value / Basis ) × Scale

Value
The current bar's volume or volatility (see INPUTS section). When set to volume, it's exactly what you would expect (the volume of the bar). When set to volatility, it's the bar's range (high - low).

Basis
A statistical threshold (Mean, Median, or Q3) plus a Sigma multiple (standard deviations). The default is set to the Mean + Sigma × 3, which represents 99.7% of data in a normal distribution. The values are derived from the current bar's equivalent in other sessions. For example, if the current bar time is 9:30 AM, all previous 9:30 AM bars would be used to get the Mean and Sigma. Thus Mean + Sigma × 3 would represent the Normal Bar Vol at 9:30 AM.

Scale
Depends on the Normalize setting, where it is 1 when set to Ratio, and 100 when set to Percent. This simply determines the plot's scale (ie. 0 to 1 vs. 0 to 100).


INPUTS
While the default configuration is recommended for a majority of use cases (see BEST PRACTICES), settings should be adjusted so most of the Normalized Plot and Linear Regression are below the Signal Zone. Only the most extreme values should exceed this area.

Normalize
Allows you to specify what should be normalized (Volume or Volatility) and how it should be measured (as a Ratio or Percentage). This sets the value and scale in the core formula.

Basis
Specifies the statistical threshold (Mean, Median, or Q3) and how many standard deviations should be added to it (Sigma). This is the basis in the core formula.

Mean is the sum of values divided by the quantity of values. It's what most people think of when they say "average."

Median is the middle value, where 50% of the data will be lower and 50% will be higher.

Q3 is short for Third Quartile, where 75% of the data will be lower and 25% will be higher (think three quarters).

Sample
Determines the maximum sample size.

All Charted Bars is the default and recommended option, and ignores the adjacent lookback number.

Lookback is not recommended, but it is available for comparisons. It uses the adjacent lookback number and is likely to produce unreliable results outside a very specific context that is not suitable for most traders. Normalization is not a moving average. Unless you have a good reason to limit the sample size, do not use this option and instead use All Charted Bars.

Show Vol. name on plot
Overlays "VOLUME" or "VOLATILITY" on the plot (whichever you've selected).

Lin. Reg.
Polynomial regressions are great for capturing non-linear patterns in data. TradingView offers a "linear regression curve", which this script uses as a substitute. If you're unfamiliar with either term, think of this like a better moving average.

You're able to specify the color, length, and multiple (how much to amplify the value). The linear regression derives its value from the normalized values.

Norm. Val.
This is the color of the normalized value of the current bar (see DATA & MATH section). You're able to specify the default, within signal, and beyond signal colors. As well as the plot style.

Fade in colors between zero and the signal
Programmatically adjust the opacity of the primary plot color based on it's normalized value. When enabled, values equal to 0 will be fully transparent, become more opaque as they move away from 0, and be fully opaque at the signal. Adjusting opacity in this way helps make difference more obvious.

Plot relative to bar direction
If enabled, the normalized value will be multiplied by -1 when a bar's open is greater than the bar's close, mirroring price direction.

Technically volume and volatility are directionless. Meaning there's really no such thing as buy volume, sell volume, positive volatility, or negative volatility. There is just volume (1 buy = 1 sell = 1 volume) and volatility (high - low). Even so, visually reflecting the net effect of pricing pressure can still be useful. That's all this setting does.

Sig. Zone
Signal zones make identifying extremes easier. They do not signal if you should buy or sell, only that the current measurement is beyond what's normal. You are able to adjust the color and bounds of the zone.

Int. Levels
Interim levels can be useful when you want to visually bracket values into high / medium / low. These levels can have a value anywhere between 0 and 1. They will automatically be multiplied by 100 when the scale is set to Percent.

Zero Line
This setting allows you to specify the visibility of the zero line to best suit your trading style.

Volume & Volatility Stats
Displays a table of core values for both volume and volatility. Specifically the actual value, threshold (mean, median, or Q3), sigma (standard deviation), basis, normalized value, and linear regression.

Correlation Stats
Displays a table of correlation statistics for the current bar, as well as the data set average. Specifically the coefficient, R2, and P-Value.

Indices & Sample Size
Displays a table of mixed data. Specifically the current bar's index within the session, the current bar's index within the sample, and the sample size used to normalize the current bar's value.


BEST PRACTICES
NVOL can tell you what's normal for 9:30 AM. RVOL and ATR can only tell you if the current value is higher or lower than a moving average.

In a normal distribution (bell curve) 99.7% of data occurs within 3 standard deviations of the mean. This is why the default basis is set to "Mean, 3"; it includes the typical day-to-day fluctuations, better contextualizing what's actually normal, minimizing false positives.

This means a ratio value greater than 1 only occurs 0.3% of the time. A series of these values warrants your attention. Which is why the default signal zone is between 1 and 2. Ratios beyond 2 would be considered extreme with the default settings.

Inversely, ratio values less than 1 (the normal daily fluctuations) also tell a story. We should expect most values to occur around the middle 3rd, which is why interim levels default to 0.33 and 0.66, visually simplifying a given move's participation. These can be set to whatever you like and only serve as visual aids for your specific trading style.

It's worth noting that the linear regression oscillates when plotted directionally, which can help clarify short term move exhaustion and continuation. Akin to a relative strength index (RSI), it may be used to inform a trading decision, but it should not be the only factor.
Release Notes
  • Added indicator page link to the top of the source code.
Linear RegressionOscillatorssentiment

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer