Standard Deviation Histogram (SDH)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262
// Only good for stocks as far as I have tested.
//@version=5
indicator("Standard Deviation Histogram", "SDH", false, precision = 2)

std_val(float src = close, int len = 200) => //{
    z = (src - ta.sma(src, len))/ta.stdev(src, len)

src = input.source(close, "Source")
len = input.int(20, "Length")
smo = input.bool(false, "Smoothing", inline = "smooth")
sml = input.int(3, "", 2, inline = "smooth")

col_grow_below = input.color(#FFCDD2, "Low Color", inline = "low")
col_fall_below = input.color(#FF5252, "", inline = "low")
col_fall_above = input.color(#B2DFDB, "High Color", inline = "high")
col_grow_above = input.color(#26A69A, "", inline = "high")

dev  = std_val(src, len)
hist = smo ? ta.sma(dev, sml) : dev

hist_col = hist >= 0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)

plot(hist, "Standard Deviation", hist_col, style = plot.style_columns)
 