Editors' picksOPEN-SOURCE SCRIPT

Updated

This script offers in-depth Z-Score analytics on price and volume for 200 symbols. Utilizing visualizations such as scatter plots, histograms, and heatmaps, it enables traders to uncover potential trade opportunities, discern market dynamics, pinpoint outliers, delve into the relationship between price and volume, and much more.

A Z-Score is a statistical measurement indicating the number of standard deviations a data point deviates from the dataset's mean. Essentially, it provides insight into a value's relative position within a group of values (mean).

- A Z-Score of**zero** means the data point is exactly at the mean.

- A**positive** Z-Score indicates the data point is above the mean.

- A**negative** Z-Score indicates the data point is below the mean.

For instance, a Z-Score of 1 indicates that the data point is 1 standard deviation above the mean, while a Z-Score of -1 indicates that the data point is 1 standard deviation below the mean. In simple terms, the more extreme the Z-Score of a data point, the more “unusual” it is within a larger context.

If data is normally distributed, the following properties can be observed:

- About 68% of the data will lie within ±1 standard deviation (z-score between -1 and 1).

- About 95% will lie within ±2 standard deviations (z-score between -2 and 2).

- About 99.7% will lie within ±3 standard deviations (z-score between -3 and 3).

Datasets like price and volume (in this context) are most often not normally distributed. While the interpretation in terms of percentage of data lying within certain ranges of z-scores (like the ones mentioned above) won't hold, the z-score can still be a useful measure of how "unusual" a data point is relative to the mean.

The aim of this indicator is to offer a unique way of screening the market for trading opportunities by conveniently visualizing where current volume and price activity stands in relation to the average. It also offers features to observe the convergent/divergent relationships between asset’s price movement and volume, observe a single symbol’s activity compared to the wider market activity and much more.

Here is an overview of a few important settings.

**Z-SCORE TYPE**

◽️ Z-Score Type: Current Z-Score

Calculates the z-score by comparing current bar’s price and volume data to the mean (moving average with any custom length, default is 20 bars). This indicates how much the current bar’s price and volume data deviates from the average over the specified period. A positive z-score suggests that the current bar's price or volume is above the mean of the last 20 bars (or the custom length set by the user), while a negative z-score means it's below that mean.

*Example: Consider an asset whose current price and volume both show deviations from their 20-bar averages. If the price's Z-Score is +1.5 and the volume's Z-Score is +2.0, it means the asset's price is 1.5 standard deviations above its average, and its trading volume is 2 standard deviations above its average. This might suggest a significant upward move with strong trading activity.*

◽️ Z-Score Type: Average Z-Score

Calculates the custom-length average of symbol's z-score. Think of it as a smoothed version of the Current Z-Score. Instead of just looking at the z-score calculated on the latest bar, it considers the average behavior over the last few bars. By doing this, it helps reduce sudden jumps and gives a clearer, steadier view of the market.

*Example: Instead of a single bar, imagine the average price and volume of an asset over the last 5 bars. If the price's 5-bar average Z-Score is +1.0 and the volume's is +1.5, it tells us that, over these recent bars, both the price and volume have been consistently above their longer-term averages, indicating sustained increase.*

◽️ Z-Score Type: Relative Z-Score

Calculates a relative z-score by comparing symbol’s current bar z-score to the mean (average z-score of all symbols in the group). This is essentially a z-score of a z-score, and it helps in understanding how a particular symbol's activity stands out not just in its own historical context, but also in relation to the broader set of symbols being analyzed. In other words, while the primary z-score tells you how unusual a bar's activity is for that specific symbol, the relative z-score informs you how that "unusualness" ranks when compared to the entire group's deviations. This can be particularly useful in identifying symbols that are outliers even among outliers, indicating exceptionally unique behaviors or opportunities.

*Example: If one asset's price Z-Score is +2.5 and volume Z-Score is +3.0, but the group's average Z-Scores are +0.5 for price and +1.0 for volume, this asset’s Relative Z-Score would be high and therefore stand out. This means that asset's price and volume activities are notably high, not just by its own standards, but also when compared to other symbols in the group.*

**DISPLAY TYPE**

◽️ Display Type: Scatter Plot

The Scatter Plot is a visual tool designed to represent values for two variables, in this case the Z-Scores of price and volume for multiple symbols. Each symbol has it's own dot with x and y coordinates:

X-Axis:*Represents the Z-Score of price. A symbol further to the right indicates a higher positive deviation in its price from its average, while a symbol to the left indicates a negative deviation.*

Y-Axis:*Represents the Z-Score of volume. A symbol positioned higher up on the plot suggests a higher positive deviation in its trading volume from its average, while one lower down indicates a negative deviation.*

Here are some guideline insights of plot positioning:

- Top-Right Quadrant (High Volume-High Price):*Symbols in this quadrant indicate a scenario where both the trading volume and price are higher than their respective mean. *

- Top-Left Quadrant (High Volume-Low Price):*Symbols here reflect high trading volumes but prices lower than the mean. *

- Bottom-Left Quadrant (Low Volume-Low Price):*Assets in this quadrant have both low trading volume and price compared to their mean. *

- Bottom-Right Quadrant (Low Volume-High Price):*Symbols positioned here have prices that are higher than their mean, but the trading volume is low compared to the mean. *

The plot also integrates a set of concentric squares which serve as visual guides:

- 1st Square (1SD):*Encapsulates symbols that have Z-Scores within ±1 standard deviation for both price and volume. Symbols within this square are typically considered to be displaying normal behavior or within expected range.*

- 2nd Square (2SD):*Encapsulates those with Z-Scores within ±2 standard deviations. Symbols within this boundary, but outside the 1 SD square, indicate a moderate deviation from the norm.*

- 3rd Square (3SD):*Represents symbols with Z-Scores within ±3 standard deviations. Any symbol outside this square is deemed to be a significant outlier, exhibiting extreme behavior in terms of either its price, its volume, or both.*

By assessing the position of symbols relative to these squares, traders can swiftly identify which assets are behaving typically and which are showing unusual activity. This visualization simplifies the process of spotting potential outliers or unique trading opportunities within the market. The farther a symbol is from the center, the more it deviates from its typical behavior.

◽️ Display Type: Columns

In this visualization, z-scores are represented using columns, where each symbol is presented horizontally. Each symbol has two distinct nodes:

- Left Node:*Represents the z-score of volume.*

- Right Node:*Represents the z-score of price.*

The height of these nodes can vary along the y-axis between -4 and 4, based on the z-score value:

- Large Positive Columns:*Signify a high or positive z-score, indicating that the price or volume is significantly above its average.*

- Large Negative Columns:*Represent a low or negative z-score, suggesting that the price or volume is considerably below its average.*

- Short Columns Near 0:*Indicate that the price or volume is close to its mean, showcasing minimal deviation.*

This columnar representation provides a clear, intuitive view of how each symbol's price and volume deviate from their respective averages.

◽️ Display Type: Circles

In this visualization style, z-scores are depicted using circles. Each symbol is horizontally aligned and represented by:

- Solid Circle:*Represents the z-score of price.*

- Transparent Circle:*Represents the z-score of volume.*

The vertical position of these circles on the y-axis ranges between -4 and 4, reflecting the z-score value:

- Circles Near the Top:*Indicate a high or positive z-score, suggesting the price or volume is well above its average.*

- Circles Near the Bottom:*Represent a low or negative z-score, pointing to the price or volume being notably below its average.*

- Circles Around the Midline (0):*Highlight that the price or volume is close to its mean, with minimal deviation.*

◽️ Display Type: Delta Columns

There's also an option to utilize Z-Score Delta Columns. For each symbol, a single column is presented, depicting the difference between the z-score of price and the z-score of volume.

The z-score delta essentially captures the disparity between how much the price and volume deviate from their respective mean:

- Positive Delta:*Indicates that the z-score of price is greater than the z-score of volume. This suggests that the price has deviated more from its average than the volume has from its own average. Such a scenario could point to price movements being more significant or pronounced compared to the changes in volume.*

- Negative Delta:*Represents that the z-score of volume is higher than the z-score of price. This might mean that there are substantial volume changes, yet the price hasn't moved as dramatically. This can be indicative of potential build-up in trading interest without an equivalent impact on price.*

- Delta Close to 0:*Means that the z-scores for price and volume are almost equal, indicating their deviations from the average are in sync.*

◽️ Display Type: Z-Volume/Z-Price Heatmap

This visualization offers a heatmap either for volume z-scores or price z-scores across all symbols. Here's how it's presented:

Each symbol is allocated its own horizontal row. Within this row, bar-by-bar data is displayed using a color gradient to represent the z-score values. The heatmap employs a user-defined gradient scale, where a chosen "cold" color represents low z-scores and a chosen "hot" color signifies high z-scores. As the z-score increases or decreases, the colors transition smoothly along this gradient, providing an intuitive visual indication of the z-score's magnitude.

- Cold Colors:*Indicate values significantly below the mean (negative z-score)*

- Mild Colors:*Represent values close to the mean, suggesting minimal deviation.*

- Hot Colors:*Indicate values significantly above the mean (positive z-score)*

This heatmap format provides a rapid, visually impactful means to discern how each symbol's price or volume is behaving relative to its average. The color-coded rows allow you to quickly spot outliers.

**VOLUME TYPE**

The "Volume Type" input allows you to choose the nature of volume data that will be factored into the volume z-score calculation. The interpretation of indicator’s data changes based on this input. You can opt between:

- Volume (Regular Volume):*This is the classic measure of trading volume, which represents the volume traded in a given time period - bar.*

- OBV (On-Balance Volume):*OBV is a momentum indicator that accumulates volume on up bars and subtracts it on down bars, making it a cumulative indicator that sort of measures buying and selling pressure.*

Interpretation Implications:

- For Volume Type: Regular Volume:

Positive Z-Score:*Indicates that the trading volume is above its average, meaning there's unusually high trading activity*.

Negative Z-Score:*Suggests that the trading volume is below its average, signifying unusually low trading activity.*

- For Volume Type: OBV:

Positive Z-Score:*Signifies that “buying pressure” is above its average.*

Negative Z-Score:*Signifies that “selling pressure” is above its average.*

When comparing Z-Score of OBV to Z-Score of price, we can observe several scenarios. If Z-Price and Z-Volume are convergent (have similar z-scores), we can say that the directional price movement is supported by volume. If Z-Price and Z-Volume are divergent (have very different z-scores or one of them being zero), it suggests a potential misalignment between price movement and volume support, which might hint at possible reversals or weakness.

A Z-Score is a statistical measurement indicating the number of standard deviations a data point deviates from the dataset's mean. Essentially, it provides insight into a value's relative position within a group of values (mean).

- A Z-Score of

- A

- A

For instance, a Z-Score of 1 indicates that the data point is 1 standard deviation above the mean, while a Z-Score of -1 indicates that the data point is 1 standard deviation below the mean. In simple terms, the more extreme the Z-Score of a data point, the more “unusual” it is within a larger context.

If data is normally distributed, the following properties can be observed:

- About 68% of the data will lie within ±1 standard deviation (z-score between -1 and 1).

- About 95% will lie within ±2 standard deviations (z-score between -2 and 2).

- About 99.7% will lie within ±3 standard deviations (z-score between -3 and 3).

Datasets like price and volume (in this context) are most often not normally distributed. While the interpretation in terms of percentage of data lying within certain ranges of z-scores (like the ones mentioned above) won't hold, the z-score can still be a useful measure of how "unusual" a data point is relative to the mean.

The aim of this indicator is to offer a unique way of screening the market for trading opportunities by conveniently visualizing where current volume and price activity stands in relation to the average. It also offers features to observe the convergent/divergent relationships between asset’s price movement and volume, observe a single symbol’s activity compared to the wider market activity and much more.

Here is an overview of a few important settings.

◽️ Z-Score Type: Current Z-Score

Calculates the z-score by comparing current bar’s price and volume data to the mean (moving average with any custom length, default is 20 bars). This indicates how much the current bar’s price and volume data deviates from the average over the specified period. A positive z-score suggests that the current bar's price or volume is above the mean of the last 20 bars (or the custom length set by the user), while a negative z-score means it's below that mean.

◽️ Z-Score Type: Average Z-Score

Calculates the custom-length average of symbol's z-score. Think of it as a smoothed version of the Current Z-Score. Instead of just looking at the z-score calculated on the latest bar, it considers the average behavior over the last few bars. By doing this, it helps reduce sudden jumps and gives a clearer, steadier view of the market.

◽️ Z-Score Type: Relative Z-Score

Calculates a relative z-score by comparing symbol’s current bar z-score to the mean (average z-score of all symbols in the group). This is essentially a z-score of a z-score, and it helps in understanding how a particular symbol's activity stands out not just in its own historical context, but also in relation to the broader set of symbols being analyzed. In other words, while the primary z-score tells you how unusual a bar's activity is for that specific symbol, the relative z-score informs you how that "unusualness" ranks when compared to the entire group's deviations. This can be particularly useful in identifying symbols that are outliers even among outliers, indicating exceptionally unique behaviors or opportunities.

◽️ Display Type: Scatter Plot

The Scatter Plot is a visual tool designed to represent values for two variables, in this case the Z-Scores of price and volume for multiple symbols. Each symbol has it's own dot with x and y coordinates:

X-Axis:

Y-Axis:

Here are some guideline insights of plot positioning:

- Top-Right Quadrant (High Volume-High Price):

- Top-Left Quadrant (High Volume-Low Price):

- Bottom-Left Quadrant (Low Volume-Low Price):

- Bottom-Right Quadrant (Low Volume-High Price):

The plot also integrates a set of concentric squares which serve as visual guides:

- 1st Square (1SD):

- 2nd Square (2SD):

- 3rd Square (3SD):

By assessing the position of symbols relative to these squares, traders can swiftly identify which assets are behaving typically and which are showing unusual activity. This visualization simplifies the process of spotting potential outliers or unique trading opportunities within the market. The farther a symbol is from the center, the more it deviates from its typical behavior.

◽️ Display Type: Columns

In this visualization, z-scores are represented using columns, where each symbol is presented horizontally. Each symbol has two distinct nodes:

- Left Node:

- Right Node:

The height of these nodes can vary along the y-axis between -4 and 4, based on the z-score value:

- Large Positive Columns:

- Large Negative Columns:

- Short Columns Near 0:

This columnar representation provides a clear, intuitive view of how each symbol's price and volume deviate from their respective averages.

◽️ Display Type: Circles

In this visualization style, z-scores are depicted using circles. Each symbol is horizontally aligned and represented by:

- Solid Circle:

- Transparent Circle:

The vertical position of these circles on the y-axis ranges between -4 and 4, reflecting the z-score value:

- Circles Near the Top:

- Circles Near the Bottom:

- Circles Around the Midline (0):

◽️ Display Type: Delta Columns

There's also an option to utilize Z-Score Delta Columns. For each symbol, a single column is presented, depicting the difference between the z-score of price and the z-score of volume.

The z-score delta essentially captures the disparity between how much the price and volume deviate from their respective mean:

- Positive Delta:

- Negative Delta:

- Delta Close to 0:

◽️ Display Type: Z-Volume/Z-Price Heatmap

This visualization offers a heatmap either for volume z-scores or price z-scores across all symbols. Here's how it's presented:

Each symbol is allocated its own horizontal row. Within this row, bar-by-bar data is displayed using a color gradient to represent the z-score values. The heatmap employs a user-defined gradient scale, where a chosen "cold" color represents low z-scores and a chosen "hot" color signifies high z-scores. As the z-score increases or decreases, the colors transition smoothly along this gradient, providing an intuitive visual indication of the z-score's magnitude.

- Cold Colors:

- Mild Colors:

- Hot Colors:

This heatmap format provides a rapid, visually impactful means to discern how each symbol's price or volume is behaving relative to its average. The color-coded rows allow you to quickly spot outliers.

The "Volume Type" input allows you to choose the nature of volume data that will be factored into the volume z-score calculation. The interpretation of indicator’s data changes based on this input. You can opt between:

- Volume (Regular Volume):

- OBV (On-Balance Volume):

Interpretation Implications:

- For Volume Type: Regular Volume:

Positive Z-Score:

Negative Z-Score:

- For Volume Type: OBV:

Positive Z-Score:

Negative Z-Score:

When comparing Z-Score of OBV to Z-Score of price, we can observe several scenarios. If Z-Price and Z-Volume are convergent (have similar z-scores), we can say that the directional price movement is supported by volume. If Z-Price and Z-Volume are divergent (have very different z-scores or one of them being zero), it suggests a potential misalignment between price movement and volume support, which might hint at possible reversals or weakness.

Release Notes

Unavailable symbol error fixed.Register to support free indicators:

BYBIT: partner.bybit.com/b/Leviathan

WOO X: referral.woo.org/7MY2

BYBIT: partner.bybit.com/b/Leviathan

WOO X: referral.woo.org/7MY2

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.

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.