Rate Of Change For -5 Percent Rule
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © 87468ee8f0384037b9e29d027af485

//@version=5
indicator(title="Rate Of Change For -5 Percent Rule", shorttitle="ROC For -5 Percent Rule", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(1, minval=1)
source1 = input(close, "Source1")
source2 = input(close, "Source2")
borderline = input.int(-5, "Borderline")
roc = 100 * (source2 - source1[length])/source1[length]
green_or_red = if roc > borderline
    color.green
else
    color.red
plot(roc, color = green_or_red, title = "Rate Of Change", style = plot.style_columns)
hline(borderline, color = color.red, linewidth = 2, linestyle = hline.style_dotted, editable = false)
