Rational Root Timeline
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OrionAlgo

//@version=5
indicator("Rational Root Timeline")

push = input.int(2922, "Push")

prediction = input.float(3.5,"Prediction")
smoothing = input.int(20, "Smoothing")

factor = input.float(0.9998)


var bar = 1.
bar:= bar*factor



_c0 = timestamp(2009, 01, 01, 00, 00)
c0_start = time >= _c0
_c1 = timestamp(2013, 01, 01, 00, 00)
c1_start = time >= _c1
_c2 = timestamp(2017, 01, 01, 00, 00)
c2_start = time >= _c2
_c3 = timestamp(2021, 01, 01, 00, 00)
c3_start = time >= _c3

c0 = c0_start? math.log(close) : na
c1 = c1_start? math.log(close) : na
c2 = c2_start? math.log(close) : na
c3 = c3_start? math.log(close) : na

p0 = c0_start? math.log(close)+(prediction*bar) : na
p1 = c1_start? math.log(close)+(prediction*bar) : na
p2 = c2_start? math.log(close)+(prediction*bar) : na
p3 = c3_start? math.log(close)+(prediction*bar) : na




p0 := ta.ema(p0,smoothing)
p1 := ta.ema(p1,smoothing)
p2 := ta.ema(p2,smoothing)
p3 := ta.ema(p3,smoothing)



c0_offset = 0 + push
c1_offset = -1461 + push
c2_offset = -2922 + push
c3_offset = -4383 + push

plot(c0,"cycle 0", offset=c0_offset, color = color.rgb(255,255,255,50))
plot(c1,"cycle 1", offset=c1_offset, color = color.rgb(255,255,255,50))
plot(c2,"cycle 2", offset=c2_offset, color = color.rgb(255,255,255,50))
plot(c3,"cycle 3", offset=c3_offset, color = color.rgb(255,255,255,50))
plot(p0,"cycle 0", offset=c0_offset, color = color.rgb(255,0,0,80))
plot(p1,"cycle 1", offset=c1_offset, color = color.rgb(255,0,0,80))
plot(p2,"cycle 2", offset=c2_offset, color = color.rgb(255,0,0,80))
plot(p3,"cycle 3", offset=c3_offset, color = color.rgb(255,0,0,80))

plot(c0, offset=c0_offset, style=plot.style_circles, show_last=1, linewidth=2, color=color.rgb(255,255,255,20))
plot(c1, offset=c1_offset, style=plot.style_circles, show_last=1, linewidth=2, color=color.rgb(255,255,255,20))
plot(c2, offset=c2_offset, style=plot.style_circles, show_last=1, linewidth=2, color=color.rgb(255,255,255,20))
plot(c3, offset=c3_offset, style=plot.style_circles, show_last=1, linewidth=2, color=color.rgb(255,255,255,20))

