It is possible to approximate the underlying distribution of a random variable by using what is called an "Histogram". In order to construct an histogram one must first split the data into several intervals (also called bins) often of the same size and count the number of values falling within each intervals, the histogram plot is then constructed with the X axis representing the measured variable and the Y axis representing the frequency.

The proposed script aim to estimate the underlying distribution of a rolling z-score by constructing its histogram, here the histogram consist of 13 bins of width 0.5 rolling standard deviations. The length setting define the rolling z-score period, the window setting define the number of past data to be counted, finally using the "Total" option (true by default) will count all the rolling z-scores values since the first bar, in order to use the window setting make sure to uncheck the "Total" option.

In order to see the entirety of the histogram make sure to double click on the indicator window and to have all the lower panels (text notes, pine editor...etc) hidden, finally make sure to zoom-in in order to see the frequency numbers displayed.

Z-Histogram on BTCUSD 15 min TF, the blue bins represent intervals situated over 0 while red bins represent intervals situated under 0. Here σ represent the X-axis in standard deviations, the histogram start with a bin situated at σ = -3 which count the number of times the rolling z-score was within -3 and -2.5, the histogram end with the bin situated at σ = 3 which count the number of time the rolling z-score was within 3 and 3.5.

It is also possible to look at the shape of the histogram without having the indicator window at full size.

An histogram can give really interesting information such as overall trend direction and strength. The direction can be measured by looking at the

Another interesting characteristic is the

An histogram applied to the rolling z-score can give various useful information. As a recall the rolling z-score of the price measure the distance between the closing price and its moving average in term of rolling standard deviations, for example if the rolling z-score is equal to 2 it means that the closing price is currently 2 rolling standard deviations over its moving average.

Lets for example analyze the histogram using INTC 15 min tf with a window of 456 bars and rolling z-score of length = 100 in order to review longer term variations.

We can see from the histogram that the uptrend visible on the chart is represented by the bins situated over 0 having an overall higher frequency than the bins under 0, we can see that the closing price tended to stay between 1 and 1.5 rolling standard deviations over its period 100 moving average. Here bins under 0 accounts for retracements in the trend.

An histogram can give various information regarding the price evolution of a security, the proposed script aim to plot the histogram of a rolling z-score. Now this script might not be too useful but it was fun to make, also it does not mean that an histogram is not an useful tool in the context of trading, the only thing required is a god implementation of it (like volume profiles for example)

In this post we have also reviewed some important statistical concepts such as distributions, z-score, skewness and tailedness, each being extremely important in the quantitative trading field.

Thx for reading !

The proposed script aim to estimate the underlying distribution of a rolling z-score by constructing its histogram, here the histogram consist of 13 bins of width 0.5 rolling standard deviations. The length setting define the rolling z-score period, the window setting define the number of past data to be counted, finally using the "Total" option (true by default) will count all the rolling z-scores values since the first bar, in order to use the window setting make sure to uncheck the "Total" option.

**DISPLAY**In order to see the entirety of the histogram make sure to double click on the indicator window and to have all the lower panels (text notes, pine editor...etc) hidden, finally make sure to zoom-in in order to see the frequency numbers displayed.

Z-Histogram on BTCUSD 15 min TF, the blue bins represent intervals situated over 0 while red bins represent intervals situated under 0. Here σ represent the X-axis in standard deviations, the histogram start with a bin situated at σ = -3 which count the number of times the rolling z-score was within -3 and -2.5, the histogram end with the bin situated at σ = 3 which count the number of time the rolling z-score was within 3 and 3.5.

It is also possible to look at the shape of the histogram without having the indicator window at full size.

**INTERPREATION**An histogram can give really interesting information such as overall trend direction and strength. The direction can be measured by looking at the

**skewness**of the histogram, with a negative skewness (the peak of the histogram situated at the right from the center) representing down-trending variations and positive skewness (the peak of the histogram situated at the left from the center) representing up-trending variations, while a symmetrical histogram could represent a ranging market. The farther away the peak of the histogram is situated from the center, the stronger the trend.Another interesting characteristic is the

**tailedness**of the histogram, which can give information about the cleanliness of the trend, for example a positive skew and high tailedness would represent a clean up-trend, as it could suggest less variations contrary to the main trend.An histogram applied to the rolling z-score can give various useful information. As a recall the rolling z-score of the price measure the distance between the closing price and its moving average in term of rolling standard deviations, for example if the rolling z-score is equal to 2 it means that the closing price is currently 2 rolling standard deviations over its moving average.

Lets for example analyze the histogram using INTC 15 min tf with a window of 456 bars and rolling z-score of length = 100 in order to review longer term variations.

We can see from the histogram that the uptrend visible on the chart is represented by the bins situated over 0 having an overall higher frequency than the bins under 0, we can see that the closing price tended to stay between 1 and 1.5 rolling standard deviations over its period 100 moving average. Here bins under 0 accounts for retracements in the trend.

**IN SUMMARY**An histogram can give various information regarding the price evolution of a security, the proposed script aim to plot the histogram of a rolling z-score. Now this script might not be too useful but it was fun to make, also it does not mean that an histogram is not an useful tool in the context of trading, the only thing required is a god implementation of it (like volume profiles for example)

In this post we have also reviewed some important statistical concepts such as distributions, z-score, skewness and tailedness, each being extremely important in the quantitative trading field.

Thx for reading !

Patreon: https://www.patreon.com/alexgrover

Become a Patreon and get access to exclusive technical indicators!

You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts

Become a Patreon and get access to exclusive technical indicators!

You can also check out some of the indicators I made for luxalgo : https://www.tradingview.com/u/LuxAlgo/#published-scripts