Percent Change of Day [ilovealgotrading]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Baby_whale_to_moon

//@version=5
indicator('Percent Change of Day [ilovealgotrading]', overlay=false, max_labels_count = 500)


TimeFrame = input.timeframe('D')
more_then0 = input.color(defval =color.rgb(37, 128, 60) ,title = "Line Colour More 0" )
less_then0 = input.color(defval =color.rgb(185, 60, 60) ,title = "Line Colour Less 0" )

is_new_day = ta.change(time(TimeFrame)) != 0 ? 1 : 0

var float per_change = 0

bar_per_change = math.round_to_mintick(ta.roc(close,1))

per_change := is_new_day ? bar_per_change : per_change + bar_per_change

color_per_change = color(na)
if (math.round_to_mintick(ta.roc(close,1))) >= 0
    color_per_change := color.lime
    color_per_change
else
    color_per_change := color.red
    color_per_change
    
bgcolor(is_new_day ? color.new(#f5ff3c, 42) : na)
plot(per_change, 'Daily Percent Change', per_change >= 0 ? more_then0 : color.rgb(185, 60, 60), linewidth = 2)
plot(math.round_to_mintick(ta.roc(close,1)), color = color_per_change, style=plot.style_columns)
