Example of how standard deviation works: 1 standard deviation contains 68% of the data, 2 SD (the default for BB) contains 95% of data, 3 SD for 99%, etc. If the data goes past that, it is considered to be outside the distribution. In statistics, data that is within the distribution is considered to be "significant".
The z-score line is colored green if it is above zero and red if it is below zero. Above zero means that the is above the average line or the middle line of the , and vice-versa if it is below. A red vertical bar is shown when the the z-score is above the upper border line to show that it is overbought and a green vertical bar is shown when the z-score is below the lower border line to show that it is oversold. This is the equivalent of when the is above and below its .
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 a publication is governed by House Rules. You can favorite it to use it on a chart.