Average Total Price From Bottom
// 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("Average Total Price From Bottom", max_bars_back=4999, overlay=true)

time1 = input.time(timestamp("18 Jan 2015 00:00 +0000"), "Bottom1")
time2 = input.time(timestamp("9 Jan 2019 00:00 +0000"), "Bottom2")
time3 = input.time(timestamp("16 Dec 2024 00:00 +0000"), "Bottom3") //update this later when the bottom is found from the 2021 bullrun
time4 = input.time(timestamp("16 Dec 2028 00:00 +0000"), "Bottom4") //update this later when the bottom is found 2 bullruns later

_c0 = timestamp(2009, 01, 01, 00, 00)
c0_start = time >= _c0
_c1 = time1
c1_start = time >= _c1
_c2 = time2
c2_start = time >= _c2
_c3 = time3
c3_start = time >= _c3
_c4 = time4
c4_start = time >= _c4



ma1 = 0.0

if c0_start
    count0 = ta.cum(1+1==2 ? 1 : 0)
    ma1 := ta.sma( close,math.round(count0))
    if c1_start
        ma1 := 0.0
else 
    ma1 := 0.0
    
ma2 = 0.0
if c1_start
    count1 = ta.cum(1+1==2 ? 1 : 0)
    ma2 := ta.sma( close,math.round(count1))
    if c2_start
        ma2 := 0.0
else 
    ma2 := 0.0
    
ma3 = 0.0
if c2_start
    count2 = ta.cum(1+1==2 ? 1 : 0)
    ma3 := ta.sma( close,math.round(count2))
    if c3_start
        ma3 := 0.0
else 
    ma3 := 0.0
    
ma4 = 0.0
if c3_start
    count3 = ta.cum(1+1==2 ? 1 : 0)
    ma4 := ta.sma( close,math.round(count3))
    if c4_start
        ma4 := 0.0
else 
    ma4 := 0.0


// count1 = ta.cum(1+1==2 ? 1 : 0)
// ma1 = ta.sma( close,math.round(count0))


plot(ma1, color=color.green)
plot(ma2, color=color.green)
plot(ma3, color=color.green)
plot(ma4, color=color.green)
