Vector MACD
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BobBasic

//@version=5
indicator(title="Vector MACD", shorttitle="Vector MACD")

vp1 = input.int(89, "Vector Period 1")
vp2 = input.int(55, "Vector Period 2")
vp3 = input.int(34, "Vector Period 3")
vp4 = input.int(21, "Vector Period 4")
vp5 = input.int(13, "Vector Period 5")
vp6 = input.int(8, "Vector Period 6")

origin_ma = ta.alma(hl2, vp1, 0.85, 6)

vector_ma1 = ta.hma(close, vp1) - origin_ma
vector_ma2 = ta.hma(close, vp2) - origin_ma
vector_ma3 = ta.hma(close, vp3) - origin_ma
vector_ma4 = ta.hma(close, vp4) - origin_ma
vector_ma5 = ta.hma(close, vp5) - origin_ma
vector_ma6 = ta.hma(close, vp6) - origin_ma

vector = (vector_ma1 + vector_ma2 + vector_ma3 + vector_ma4 + vector_ma5 + vector_ma6) / 6

normalize(_src, _cap) =>
    xMax = ta.highest(_src, _cap)
    xMin = ta.lowest(_src, _cap)
    _range = xMax - xMin
    n = _cap * _src / _range
    n

hline(50, "Zero Line", color=color.gray)
hline(0, "Zero Line", color=color.gray, linestyle = hline.style_dotted, linewidth = 2)
hline(-50, "Zero Line", color=color.gray)
plot(normalize(vector, 100),"vmacd" , color= vector < vector[1] ? color.red : color.green, linewidth = 2)
