FDAX Impulse Times
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © reichel-holding

//@version=5
indicator("Impulse Times", overlay=true)
tgw1 = timestamp(year, month, dayofmonth,9,0,0)
tgw2 = timestamp(year, month, dayofmonth,16,0,0)
tgw3 = timestamp(year, month, dayofmonth,21,0,0)

black = color.rgb(0, 0, 0, 0)
green = color.new(#66bb6a, 65)
yellow = color.new(#e2a76b, 65)

if(timeframe.period == "1")

    
    //var barUpLeftDef = int(ta.lowest(300)[1]) - 100
    barUpLeft = input.int(title="Y-Position of Impulse bars", defval=14140)
    
    
    if (time == tgw1 or time == tgw2 or time == tgw3)
        line.new(bar_index, close, bar_index, high*2, extend = extend.both, color=black, style=line.style_dashed, width=2)
        
    firstBarTimeStart = timestamp(year, month, dayofmonth,8,30,0)
    if(time == firstBarTimeStart and not na(timeframe.period))
        lastIndex= (2 * 60 / timeframe.multiplier) + bar_index
        box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
        
    secondBarTimeStart = timestamp(year, month, dayofmonth,10,30,0)
    if(time == secondBarTimeStart and not na(timeframe.period))
        lastIndex= (5 * 60 / timeframe.multiplier) + bar_index
        box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=yellow, border_width=0)
        
    thirdBarTimeStart = timestamp(year, month, dayofmonth,15,30,0)
    if(time == thirdBarTimeStart and not na(timeframe.period))
        lastIndex= (90 / timeframe.multiplier) + bar_index
        box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
        
    fourthBarTimeStart = timestamp(year, month, dayofmonth,17,00,0)
    if(time == fourthBarTimeStart and not na(timeframe.period))
        lastIndex= (210 / timeframe.multiplier) + bar_index
        box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=yellow, border_width=0)
        
    fifthBarTimeStart = timestamp(year, month, dayofmonth,20,30,0)
    if(time == fifthBarTimeStart and not na(timeframe.period))
        lastIndex= (90 / timeframe.multiplier) + bar_index
        box.new(left=bar_index, top=barUpLeft, right=lastIndex, bottom=barUpLeft-70, bgcolor=green, border_width=0)
