Multi-period ROC
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © swanidhi

//@version=5
indicator("Multi-period ROC")

s = input(10, "Short Period")
m = input(21, "Medium Period")
l = input(45, "Long Period")
enableOnWeekly = input.bool(false, "Enable on Weekly Charts")

rocS = ta.roc(close, 10)
rocM = ta.roc(close, 21)
rocL = ta.roc(close, 45)

goS = ta.roc(close, 10) >0
goM = ta.roc(close, 21) >0
goL = ta.roc(close, 45) >0

bullTrend = goS and goM and goL

bgcolor((timeframe.isdaily or (timeframe.isweekly and enableOnWeekly)) and bullTrend?color.new(color.green, 90):na)

plot(rocS, "Short Term", color=color.red)
plot(rocM, "Medium Term", color=color.purple)
plot(rocL, "Long Term", color=color.black)
hline(0)
