Rollover LTE
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Skipper86

//@version=5
indicator(title="Rollover LTE", shorttitle="Rollover LTE", overlay=true)

//Generic input, not intended to be changed
source = input.source(close)

//Input
length1 = input.int(20, "Length 1", minval=1)
length2 = input.int(50, "Length 2", minval=1)

RolloverPrice1 = source[length1]
RolloverPrice2 = source[length2]

RolloverStrength1 = source-RolloverPrice1
RolloverStrength2 = source-RolloverPrice2

RolloverStrength = RolloverStrength1 + RolloverStrength2

MA1 = ta.sma(source, length1)
MA2 = ta.sma(source, length2)

Upper = math.max(RolloverPrice1,RolloverPrice2,MA1,MA2)
Lower = math.min(RolloverPrice1,RolloverPrice2,MA1,MA2)

Color1 = color.rgb(229, 229, 229, 0)
Color2 = color.rgb(0, 97, 255, 0)

Color6 = RolloverStrength >= 0 ? color.rgb(0,255,2,70) : color.rgb(255,0,0,70)

plot(source, offset = length1, title="Rollover Price 1", color=Color1)
plot(source, offset = length2, title="Rollover Price 2", color=Color2)

plot(MA1, title="SMA 1", color=Color1)
plot(MA2, title="SMA 2", color=Color2)
p1 = plot(Upper, title="Max", color=Color1, display=display.none)
p2 = plot(Lower, title="Min", color=Color1, display=display.none)
fill(p1, p2, title = "Background", color=Color6)