MACD-V Volatility Normalisation
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jamiedubauskas

//@version=5
indicator(title = "MACD-V Volatility Normalisation", shorttitle = "MACD-V Volatility Normalisation", overlay = false)

// asking for inputs for the parameters of the MACD-V indicator
fast_len = input.int(title = "MACD Fast Length", defval = 12, minval = 1, group = "Indicator Settings")
slow_len = input.int(title = "MACD Slow Length", defval = 26, minval = 1, group = "Indicator Settings")
source = input.source(title = "Source", defval = close, group = "Indicator Settings")
signal_len = input.int(title = "Signal Line Smoothing Length", defval = 9, minval = 1, group = "Indicator Settings")
atr_len = input.int(title = "ATR Length", defval = 26, minval = 1, tooltip = "Used to gauge volatility to standardize MACD. Keep at the same value as the MACD Slow Length parameter for best results", group = "Indicator Settings")



// indicator calculation
macd = ((ta.ema(source, fast_len) - ta.ema(source, slow_len)) / ta.atr(atr_len)) * 100
signal = ta.ema(macd, signal_len)
hist = macd - signal


// asking for input for the color of the macd and signal lines
macd_color = input.color(title = "MACD Line", defval = #2962FF, group = "Color Settings")
signal_color = input.color(title = "Signal Line", defval = #FF6D00, group = "Color Settings")

// getting colors for the histogram
col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")

macd_plot = plot(title = "MACD Line", series = macd, color = macd_color)
plot(title = "Signal Line", series = signal, color = signal_color)




