Momentum Score
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlexanderRios

//@version=5
indicator(title='Momentum Score', shorttitle='MS', format=format.price, precision=2, timeframe='')
len1 = input.int(1, minval=1)
len2 = input.int(3, minval=1)
len3 = input.int(6, minval=1)
len4 = input.int(12, minval=1)
w1 = input.int(12, minval=0)
w2 = input.int(4, minval=0)
w3 = input.int(2, minval=0)
w4 = input.int(1, minval=0)

source = input(close, 'Source')
roc1 = ta.roc(source, len1)
roc2 = ta.roc(source, len2)
roc3 = ta.roc(source, len3)
roc4 = ta.roc(source, len4)

// Momentum Score
ms = w1 * roc1 + w2 * roc2 + w3 * roc3 + w4 * roc4
plot(ms, title='Momentum Score (MS)', style=plot.style_histogram, color=ms > 0 ? color.green : color.red)
hline(0, color=#C0C0C0, title='Zero Line')